From 5f31bf45d47571d0638473c7327a104ccadc4af5 Mon Sep 17 00:00:00 2001 From: flycash Date: Sat, 6 Jun 2020 18:25:40 +0800 Subject: [PATCH] Fix #3949 : store RouterPattern before filter execute so that filter can use the pattern --- router.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/router.go b/router.go index e71366b4..b335fca9 100644 --- a/router.go +++ b/router.go @@ -750,19 +750,22 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request) } } - //execute middleware filters + if routerInfo != nil { + // store router pattern into context + context.Input.SetData("RouterPattern", routerInfo.pattern) + } + + // execute middleware filters if len(p.filters[BeforeExec]) > 0 && p.execFilter(context, urlPath, BeforeExec) { goto Admin } - //check policies + // check policies if p.execPolicy(context, urlPath) { goto Admin } if routerInfo != nil { - //store router pattern into context - context.Input.SetData("RouterPattern", routerInfo.pattern) if routerInfo.routerType == routerTypeRESTFul { if _, ok := routerInfo.methods[r.Method]; ok { isRunnable = true