File tree 1 file changed +10
-4
lines changed
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 {
130
130
// toHandlerProvider converts a handler to a handler provider
131
131
// A handler provider is a function that takes a "next" http.Handler, it can be used as a middleware
132
132
func 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
-
137
133
funcInfo := routing .GetFuncInfo (handler )
138
134
fn := reflect .ValueOf (handler )
139
135
if fn .Type ().Kind () != reflect .Func {
140
136
panic (fmt .Sprintf ("handler must be a function, but got %s" , fn .Type ()))
141
137
}
142
138
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
+
143
149
provider := func (next http.Handler ) http.Handler {
144
150
return http .HandlerFunc (func (respOrig http.ResponseWriter , req * http.Request ) {
145
151
// wrap the response writer to check whether the response has been written
You can’t perform that action at this time.
0 commit comments