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 {
|
func httpHealth(l int) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
if !serve(l) {
|
if !serve(l) {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
http.Error(w, fmt.Sprintf(`{"status":"FAIL","requests":"%v"}`, C.Get()), http.StatusInternalServerError)
|
||||||
fmt.Fprintf(w, `{"status":"FAIL","requests":"%v"}`, C.Get())
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, `{"status":"ok","requests":"%v"}`, C.Get())
|
fmt.Fprintf(w, `{"status":"ok","requests":"%v"}`, C.Get())
|
||||||
@ -116,8 +115,7 @@ func reset(rt string) http.HandlerFunc {
|
|||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
t := r.FormValue("TOKEN")
|
t := r.FormValue("TOKEN")
|
||||||
if len(t) == 0 || t != rt {
|
if len(t) == 0 || t != rt {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
http.Error(w, "Bad request, invalid token", http.StatusBadRequest)
|
||||||
fmt.Fprintf(w, "Bad request, invalid token")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
C.Reset()
|
C.Reset()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user