chore: add status code for request_total metrics (#5188)
This commit is contained in:
committed by
GitHub
parent
fe417ee02d
commit
a7fc723ae0
21
weed/stats/http_status_recorder.go
Normal file
21
weed/stats/http_status_recorder.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package stats
|
||||
|
||||
import "net/http"
|
||||
|
||||
type StatusRecorder struct {
|
||||
http.ResponseWriter
|
||||
Status int
|
||||
}
|
||||
|
||||
func NewStatusResponseWriter(w http.ResponseWriter) *StatusRecorder {
|
||||
return &StatusRecorder{w, http.StatusOK}
|
||||
}
|
||||
|
||||
func (r *StatusRecorder) WriteHeader(status int) {
|
||||
r.Status = status
|
||||
r.ResponseWriter.WriteHeader(status)
|
||||
}
|
||||
|
||||
func (r *StatusRecorder) Flush() {
|
||||
r.ResponseWriter.(http.Flusher).Flush()
|
||||
}
|
||||
Reference in New Issue
Block a user