feat: switch to http.Error()
This commit is contained in:
parent
d10e8c866b
commit
05dc6e83ed
6
main.go
6
main.go
@ -102,8 +102,7 @@ func handler(l int) http.HandlerFunc {
|
||||
func httpHealth(l int) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if !serve(l) {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
fmt.Fprintf(w, `{"status":"FAIL","requests":"%v"}`, C.Get())
|
||||
http.Error(w, fmt.Sprintf(`{"status":"FAIL","requests":"%v"}`, C.Get()), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(w, `{"status":"ok","requests":"%v"}`, C.Get())
|
||||
@ -116,8 +115,7 @@ func reset(rt string) http.HandlerFunc {
|
||||
r.ParseForm()
|
||||
t := r.FormValue("TOKEN")
|
||||
if len(t) == 0 || t != rt {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Fprintf(w, "Bad request, invalid token")
|
||||
http.Error(w, "Bad request, invalid token", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
C.Reset()
|
||||
|
Loading…
x
Reference in New Issue
Block a user