File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -130,16 +130,22 @@ func hasResponseBeenWritten(argsIn []reflect.Value) bool {
130130// toHandlerProvider converts a handler to a handler provider
131131// A handler provider is a function that takes a "next" http.Handler, it can be used as a middleware
132132func toHandlerProvider (handler any ) func (next http.Handler ) http.Handler {
133- if hp , ok := handler .(func (next http.Handler ) http.Handler ); ok {
134- return hp
135- }
136-
137133 funcInfo := routing .GetFuncInfo (handler )
138134 fn := reflect .ValueOf (handler )
139135 if fn .Type ().Kind () != reflect .Func {
140136 panic (fmt .Sprintf ("handler must be a function, but got %s" , fn .Type ()))
141137 }
142138
139+ if hp , ok := handler .(func (next http.Handler ) http.Handler ); ok {
140+ return func (next http.Handler ) http.Handler {
141+ h := hp (next ) // this handle could be dynamically generated, so we can't use it for debug info
142+ return http .HandlerFunc (func (resp http.ResponseWriter , req * http.Request ) {
143+ routing .UpdateFuncInfo (req .Context (), funcInfo )
144+ h .ServeHTTP (resp , req )
145+ })
146+ }
147+ }
148+
143149 provider := func (next http.Handler ) http.Handler {
144150 return http .HandlerFunc (func (respOrig http.ResponseWriter , req * http.Request ) {
145151 // wrap the response writer to check whether the response has been written
You can’t perform that action at this time.
0 commit comments