aboutsummaryrefslogtreecommitdiffhomepage
path: root/http
diff options
context:
space:
mode:
Diffstat (limited to 'http')
-rw-r--r--http/response/json/json.go6
-rw-r--r--http/response/response.go12
2 files changed, 12 insertions, 6 deletions
diff --git a/http/response/json/json.go b/http/response/json/json.go
index ff0f06b..6f3eb15 100644
--- a/http/response/json/json.go
+++ b/http/response/json/json.go
@@ -9,14 +9,14 @@ import (
"errors"
"net/http"
+ "github.com/miniflux/miniflux/http/response"
"github.com/miniflux/miniflux/logger"
)
// OK sends a JSON response with the status code 200.
-func OK(w http.ResponseWriter, v interface{}) {
+func OK(w http.ResponseWriter, r *http.Request, v interface{}) {
commonHeaders(w)
- w.WriteHeader(http.StatusOK)
- w.Write(toJSON(v))
+ response.Compress(w, r, toJSON(v))
}
// Created sends a JSON response with the status code 201.
diff --git a/http/response/response.go b/http/response/response.go
index c5ae3fa..f792625 100644
--- a/http/response/response.go
+++ b/http/response/response.go
@@ -23,7 +23,7 @@ func NotModified(w http.ResponseWriter) {
}
// Cache returns a response with caching headers.
-func Cache(w http.ResponseWriter, r *http.Request, mimeType, etag string, content []byte, duration time.Duration) {
+func Cache(w http.ResponseWriter, r *http.Request, mimeType, etag string, data []byte, duration time.Duration) {
w.Header().Set("Content-Type", mimeType)
w.Header().Set("ETag", etag)
w.Header().Set("Cache-Control", "public")
@@ -31,8 +31,14 @@ func Cache(w http.ResponseWriter, r *http.Request, mimeType, etag string, conten
if etag == r.Header.Get("If-None-Match") {
w.WriteHeader(http.StatusNotModified)
- } else {
- w.Write(content)
+ return
+ }
+
+ switch mimeType {
+ case "text/javascript; charset=utf-8", "text/css; charset=utf-8":
+ Compress(w, r, data)
+ default:
+ w.Write(data)
}
}