File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -102,8 +102,7 @@ func (r *Route) Match(req *http.Request, match *RouteMatch) bool {
102
102
match .Route = r
103
103
}
104
104
if match .Handler == nil {
105
- // for the matched handler, wrap it in the assigned middlewares
106
- match .Handler = r .WrapHandlerInMiddlewares (r .handler )
105
+ match .Handler = r .GetHandlerWithMiddlewares ()
107
106
}
108
107
109
108
// Set variables.
@@ -146,10 +145,12 @@ func (r *Route) GetHandler() http.Handler {
146
145
return r .handler
147
146
}
148
147
149
- // WrapHandlerInMiddleware wraps the route handler in the assigned middlewares.
150
- // If no middlewares are specified, just the handler is returned.
151
- func (r * Route ) WrapHandlerInMiddlewares (handler http.Handler ) http.Handler {
152
- if len (r .middlewares ) > 0 {
148
+ // GetHandlerWithMiddleware returns the route handler wrapped in the assigned middlewares.
149
+ // If no middlewares are specified, just the handler, if any, is returned.
150
+ func (r * Route ) GetHandlerWithMiddlewares () http.Handler {
151
+ handler := r .handler
152
+
153
+ if handler != nil && len (r .middlewares ) > 0 {
153
154
for i := len (r .middlewares ) - 1 ; i >= 0 ; i -- {
154
155
handler = r .middlewares [i ].Middleware (handler )
155
156
}
You can’t perform that action at this time.
0 commit comments