mirror of
https://github.com/octoleo/syncthing.git
synced 2024-09-19 05:09:01 +00:00
cmd/strelaypoolsrv: Correctly account status codes, tweak status codes
This commit is contained in:
parent
48f9d323fa
commit
66262392c3
@ -334,10 +334,10 @@ func mimeTypeForFile(file string) string {
|
|||||||
func handleRequest(w http.ResponseWriter, r *http.Request) {
|
func handleRequest(w http.ResponseWriter, r *http.Request) {
|
||||||
timer := prometheus.NewTimer(apiRequestsSeconds.WithLabelValues(r.Method))
|
timer := prometheus.NewTimer(apiRequestsSeconds.WithLabelValues(r.Method))
|
||||||
|
|
||||||
lw := NewLoggingResponseWriter(w)
|
w = NewLoggingResponseWriter(w)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
timer.ObserveDuration()
|
timer.ObserveDuration()
|
||||||
|
lw := w.(*loggingResponseWriter)
|
||||||
apiRequestsTotal.WithLabelValues(r.Method, strconv.Itoa(lw.statusCode)).Inc()
|
apiRequestsTotal.WithLabelValues(r.Method, strconv.Itoa(lw.statusCode)).Inc()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ func handlePostRequest(w http.ResponseWriter, r *http.Request) {
|
|||||||
if debug {
|
if debug {
|
||||||
log.Println("Failed to parse payload")
|
log.Println("Failed to parse payload")
|
||||||
}
|
}
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ func handlePostRequest(w http.ResponseWriter, r *http.Request) {
|
|||||||
if debug {
|
if debug {
|
||||||
log.Println("Failed to parse URI", newRelay.URL)
|
log.Println("Failed to parse URI", newRelay.URL)
|
||||||
}
|
}
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,7 +415,7 @@ func handlePostRequest(w http.ResponseWriter, r *http.Request) {
|
|||||||
if debug {
|
if debug {
|
||||||
log.Println("Failed to split URI", newRelay.URL)
|
log.Println("Failed to split URI", newRelay.URL)
|
||||||
}
|
}
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user