diff --git a/VERSION b/VERSION index 15421b3..63c16ce 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.7.16 +1.7.17 diff --git a/birdwatcher.go b/birdwatcher.go index 7144098..66d3c7f 100644 --- a/birdwatcher.go +++ b/birdwatcher.go @@ -13,7 +13,7 @@ import ( ) //go:generate versionize -var VERSION = "1.7.16" +var VERSION = "1.7.17" func isModuleEnabled(module string, modulesEnabled []string) bool { for _, enabled := range modulesEnabled { diff --git a/endpoints/endpoint.go b/endpoints/endpoint.go index dfe07b7..78dfb51 100644 --- a/endpoints/endpoint.go +++ b/endpoints/endpoint.go @@ -5,6 +5,7 @@ import ( "log" "strings" + "compress/gzip" "encoding/json" "net/http" @@ -67,7 +68,14 @@ func Endpoint(wrapped endpoint) httprouter.Handle { js, _ := json.Marshal(res) w.Header().Set("Content-Type", "application/json") - w.Write(js) + if !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { + w.Write(js) + } else { + w.Header().Set("Content-Encoding", "gzip") + gz := gzip.NewWriter(w) + defer gz.Close() + gz.Write(js) + } } }