|
|
|
@ -128,6 +128,16 @@ func hasResponseBeenWritten(argsIn []reflect.Value) bool { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func wrapHandlerProvider[T http.Handler](hp func(next http.Handler) T, funcInfo *routing.FuncInfo) func(next http.Handler) http.Handler { |
|
|
|
|
return func(next http.Handler) http.Handler { |
|
|
|
|
h := hp(next) // this handle could be dynamically generated, so we can't use it for debug info
|
|
|
|
|
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { |
|
|
|
|
routing.UpdateFuncInfo(req.Context(), funcInfo) |
|
|
|
|
h.ServeHTTP(resp, req) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// toHandlerProvider converts a handler to a handler provider
|
|
|
|
|
// A handler provider is a function that takes a "next" http.Handler, it can be used as a middleware
|
|
|
|
|
func toHandlerProvider(handler any) func(next http.Handler) http.Handler { |
|
|
|
@ -138,13 +148,9 @@ func toHandlerProvider(handler any) func(next http.Handler) http.Handler { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if hp, ok := handler.(func(next http.Handler) http.Handler); ok { |
|
|
|
|
return func(next http.Handler) http.Handler { |
|
|
|
|
h := hp(next) // this handle could be dynamically generated, so we can't use it for debug info
|
|
|
|
|
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { |
|
|
|
|
routing.UpdateFuncInfo(req.Context(), funcInfo) |
|
|
|
|
h.ServeHTTP(resp, req) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
return wrapHandlerProvider(hp, funcInfo) |
|
|
|
|
} else if hp, ok := handler.(func(http.Handler) http.HandlerFunc); ok { |
|
|
|
|
return wrapHandlerProvider(hp, funcInfo) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
provider := func(next http.Handler) http.Handler { |
|
|
|
|