Skip to content

Commit 16a2f54

Browse files
authored
Add response compression wrapper for query api (#6844)
* add response compression wrapper to query api Signed-off-by: Ahmed Hassan <[email protected]> * fix formatting Signed-off-by: Ahmed Hassan <[email protected]> --------- Signed-off-by: Ahmed Hassan <[email protected]>
1 parent 7640265 commit 16a2f54

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/api/queryapi/query_api.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (q *QueryAPI) InstantQueryHandler(r *http.Request) (result apiFuncResult) {
188188
}
189189

190190
func (q *QueryAPI) Wrap(f apiFunc) http.HandlerFunc {
191-
return func(w http.ResponseWriter, r *http.Request) {
191+
hf := func(w http.ResponseWriter, r *http.Request) {
192192
httputil.SetCORS(w, q.CORSOrigin, r)
193193

194194
result := f(r)
@@ -207,6 +207,10 @@ func (q *QueryAPI) Wrap(f apiFunc) http.HandlerFunc {
207207
}
208208
w.WriteHeader(http.StatusNoContent)
209209
}
210+
211+
return httputil.CompressionHandler{
212+
Handler: http.HandlerFunc(hf),
213+
}.ServeHTTP
210214
}
211215

212216
func (q *QueryAPI) respond(w http.ResponseWriter, req *http.Request, data interface{}, warnings annotations.Annotations, query string) {

0 commit comments

Comments
 (0)