Skip to content

Commit

Permalink
switch order of operations when writing status code
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski authored Oct 19, 2020
1 parent 13412ec commit 89780e6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ func writeBadRequest(w http.ResponseWriter, err error) {
// writeJSON writes the json-encoded error message to the response
// with a 400 bad request status code.
func writeJSON(w http.ResponseWriter, v interface{}, status int) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.Header().Set("X-Content-Type-Options", "nosniff")
w.WriteHeader(status)
w.Header().Set("Content-Type", "application/json")
enc := json.NewEncoder(w)
if indent {
enc.SetIndent("", " ")
Expand Down

0 comments on commit 89780e6

Please sign in to comment.