json.go 335 B

1234567891011
  1. package middleware
  2. import "net/http"
  3. // ContentTypeJSON sets the content type for requests to application/json
  4. func ContentTypeJSON(next http.Handler) http.Handler {
  5. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  6. w.Header().Set("Content-Type", "application/json;charset=utf8")
  7. next.ServeHTTP(w, r)
  8. })
  9. }