|
|
|
@ -249,6 +249,9 @@ func (api *API) Register(r *route.Router) {
|
|
|
|
|
hf := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
httputil.SetCORS(w, api.CORSOrigin, r)
|
|
|
|
|
result := f(r)
|
|
|
|
|
if result.finalizer != nil {
|
|
|
|
|
defer result.finalizer()
|
|
|
|
|
}
|
|
|
|
|
if result.err != nil {
|
|
|
|
|
api.respondError(w, result.err, result.data)
|
|
|
|
|
} else if result.data != nil {
|
|
|
|
@ -256,9 +259,6 @@ func (api *API) Register(r *route.Router) {
|
|
|
|
|
} else {
|
|
|
|
|
w.WriteHeader(http.StatusNoContent)
|
|
|
|
|
}
|
|
|
|
|
if result.finalizer != nil {
|
|
|
|
|
result.finalizer()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return api.ready(httputil.CompressionHandler{
|
|
|
|
|
Handler: hf,
|
|
|
|
|