mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-13 06:47:28 -08:00
Defer finalizer (#7129)
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
parent
1d6532e9e5
commit
209d4bb8a1
|
@ -250,6 +250,9 @@ func (api *API) Register(r *route.Router) {
|
||||||
hf := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
hf := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
httputil.SetCORS(w, api.CORSOrigin, r)
|
httputil.SetCORS(w, api.CORSOrigin, r)
|
||||||
result := f(r)
|
result := f(r)
|
||||||
|
if result.finalizer != nil {
|
||||||
|
defer result.finalizer()
|
||||||
|
}
|
||||||
if result.err != nil {
|
if result.err != nil {
|
||||||
api.respondError(w, result.err, result.data)
|
api.respondError(w, result.err, result.data)
|
||||||
} else if result.data != nil {
|
} else if result.data != nil {
|
||||||
|
@ -257,9 +260,6 @@ func (api *API) Register(r *route.Router) {
|
||||||
} else {
|
} else {
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
}
|
}
|
||||||
if result.finalizer != nil {
|
|
||||||
result.finalizer()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return api.ready(httputil.CompressionHandler{
|
return api.ready(httputil.CompressionHandler{
|
||||||
Handler: hf,
|
Handler: hf,
|
||||||
|
|
Loading…
Reference in a new issue