mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 04:52:35 +02:00
fix server responding incorrect status code
This commit is contained in:
parent
99fbb31554
commit
9731d28ec3
1 changed files with 2 additions and 2 deletions
|
@ -49,15 +49,15 @@ func ClientError(w http.ResponseWriter, err error, code ...int) {
|
|||
json.NewEncoder(w).Encode(err)
|
||||
} else {
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
http.Error(w, err.Error(), code[0])
|
||||
}
|
||||
http.Error(w, err.Error(), code[0])
|
||||
}
|
||||
|
||||
// JSONError returns a JSON response of gperr.Error with the given status code.
|
||||
func JSONError(w http.ResponseWriter, err gperr.Error, code int) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(code)
|
||||
json.NewEncoder(w).Encode(err)
|
||||
http.Error(w, err.Error(), code)
|
||||
}
|
||||
|
||||
// BadRequest returns a Bad Request response with the given error message.
|
||||
|
|
Loading…
Add table
Reference in a new issue