Serving gziped connect via HTTP in golang
The builtin HTTP server in the golang standard library does not serve gziped content. However you can relatively easily add a wrapper function to compress data on the fly. The best tool to do this appears to be go.httpgzip. A basic example of its usage might look like this:
1 2 3 4 5 6 7 8 9 10 11 12 | import ( "github.com/daaku/go.httpgzip" "net/http" ) func main() { http.Handle( "/" , httpgzip.NewHandler(http.FileServer(http.Dir( "." )))) err := http.ListenAndServe( ":80" , nil) if err != nil { panic( "Error: " + err.Error()) } } |