Fix content-type header
This commit is contained in:
@ -342,5 +342,6 @@ func (app *application) GetElection(w http.ResponseWriter, r *http.Request, id i
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write(response)
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
|
||||
func (app *application) serverError(w http.ResponseWriter, r *http.Request, err error) {
|
||||
app.logger.Error(err.Error())
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
var response = api.ErrorResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
@ -20,6 +21,7 @@ func (app *application) serverError(w http.ResponseWriter, r *http.Request, err
|
||||
}
|
||||
|
||||
func (app *application) badRequestError(w http.ResponseWriter, r *http.Request, err error) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
var response = api.ErrorResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
@ -29,6 +31,7 @@ func (app *application) badRequestError(w http.ResponseWriter, r *http.Request,
|
||||
}
|
||||
|
||||
func (app *application) clientError(w http.ResponseWriter, status int, message string) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(status)
|
||||
var response = api.ErrorResponse{
|
||||
Code: status,
|
||||
@ -39,6 +42,7 @@ func (app *application) clientError(w http.ResponseWriter, status int, message s
|
||||
}
|
||||
|
||||
func (app *application) unprocessableEntityError(w http.ResponseWriter, v validator.Validator) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||
var response = api.ErrorResponse{
|
||||
Code: http.StatusUnprocessableEntity,
|
||||
|
Reference in New Issue
Block a user