Move voting to a new endpoint
/election/{id}/votes
This commit is contained in:
@ -22,11 +22,9 @@ func (app *application) serverError(w http.ResponseWriter, r *http.Request, err
|
||||
func (app *application) clientError(w http.ResponseWriter, status int, message string) {
|
||||
w.WriteHeader(status)
|
||||
var response = api.ErrorResponse{
|
||||
Code: http.StatusUnprocessableEntity,
|
||||
Details: &map[string]interface{}{
|
||||
"error": message,
|
||||
},
|
||||
Message: "There was an error in the request",
|
||||
Code: status,
|
||||
Details: nil,
|
||||
Message: message,
|
||||
}
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
@ -38,16 +36,7 @@ func (app *application) unprocessableEntityError(w http.ResponseWriter, v valida
|
||||
Details: &map[string]interface{}{
|
||||
"fields": v.FieldErrors,
|
||||
},
|
||||
Message: "Election data is invalid",
|
||||
}
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
func (app *application) unprocessableEntityErrorSingle(w http.ResponseWriter, err error) {
|
||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||
var response = api.ErrorResponse{
|
||||
Code: http.StatusUnprocessableEntity,
|
||||
Message: err.Error(),
|
||||
Message: "Request data is invalid",
|
||||
}
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
Reference in New Issue
Block a user