Documentation ¶
Overview ¶
package htmxgo provides utilities for serving htmx library.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServeHTTP ¶
func ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP serves the htmx library. Compression is supported. Sets Content-Type to application/javascript. Tries to use the best compression available by Accept-Encoding header. Concurrent safe.
Example ¶
package main import ( "fmt" "net/http" "net/http/httptest" htmxgo "github.com/ninedraft/htmx-go" ) func main() { req := httptest.NewRequest("GET", "/htmx.min.js", nil) req.Header.Set("Accept-Encoding", "br") mux := http.NewServeMux() mux.HandleFunc("/htmx.min.js", htmxgo.ServeHTTP) rw := httptest.NewRecorder() mux.ServeHTTP(rw, req) fmt.Println(rw.Header().Get("Content-Encoding")) fmt.Println(rw.Header().Get("Content-Type")) }
Output: br application/javascript
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.