2022-05-12 17:41:39 +03:00
|
|
|
package websvc
|
|
|
|
|
2023-04-07 14:21:37 +03:00
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
|
|
|
|
"github.com/AdguardTeam/golibs/httphdr"
|
|
|
|
)
|
2022-05-12 17:41:39 +03:00
|
|
|
|
|
|
|
// Middlewares
|
|
|
|
|
|
|
|
// jsonMw sets the content type of the response to application/json.
|
|
|
|
func jsonMw(h http.Handler) (wrapped http.HandlerFunc) {
|
|
|
|
f := func(w http.ResponseWriter, r *http.Request) {
|
2023-04-07 14:21:37 +03:00
|
|
|
w.Header().Set(httphdr.ContentType, aghhttp.HdrValApplicationJSON)
|
2022-05-12 17:41:39 +03:00
|
|
|
|
|
|
|
h.ServeHTTP(w, r)
|
|
|
|
}
|
|
|
|
|
|
|
|
return http.HandlerFunc(f)
|
|
|
|
}
|