diff --git a/internal/aghhttp/aghhttp.go b/internal/aghhttp/aghhttp.go index b5878f92..6cb2c670 100644 --- a/internal/aghhttp/aghhttp.go +++ b/internal/aghhttp/aghhttp.go @@ -72,8 +72,8 @@ func WriteJSONResponse(w http.ResponseWriter, r *http.Request, resp any) (err er // WriteJSONResponseCode is like [WriteJSONResponse] but adds the ability to // redefine the status code. func WriteJSONResponseCode(w http.ResponseWriter, r *http.Request, code int, resp any) (err error) { - w.WriteHeader(code) w.Header().Set(httphdr.ContentType, HdrValApplicationJSON) + w.WriteHeader(code) err = json.NewEncoder(w).Encode(resp) if err != nil { Error(r, w, http.StatusInternalServerError, "encoding resp: %s", err)