diff --git a/router.go b/router.go index 4d195bc8..ca6d917a 100644 --- a/router.go +++ b/router.go @@ -611,19 +611,21 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) if p.enableFilter { if l, ok := p.filters[pos]; ok { for _, filterR := range l { - if ok, p := filterR.ValidRouter(urlPath); ok { - for k, v := range p { + if filterR.returnOnOutput && w.started { + return true + } + if ok, params := filterR.ValidRouter(urlPath); ok { + for k, v := range params { context.Input.Params[k] = v } filterR.filterFunc(context) - if filterR.returnOnOutput && w.started { - return true - } + } + if filterR.returnOnOutput && w.started { + return true } } } } - return false } diff --git a/router_test.go b/router_test.go index ee712167..005f32d6 100644 --- a/router_test.go +++ b/router_test.go @@ -444,7 +444,7 @@ func TestFilterAfterExec(t *testing.T) { mux := NewControllerRegister() mux.InsertFilter(url, BeforeRouter, beegoFilterNoOutput) mux.InsertFilter(url, BeforeExec, beegoFilterNoOutput) - mux.InsertFilter(url, AfterExec, beegoAfterExec1) + mux.InsertFilter(url, AfterExec, beegoAfterExec1, false) mux.Get(url, beegoFilterFunc) @@ -506,7 +506,7 @@ func TestFilterFinishRouterMultiFirstOnly(t *testing.T) { url := "/finishRouterMultiFirstOnly" mux := NewControllerRegister() - mux.InsertFilter(url, FinishRouter, beegoFinishRouter1) + mux.InsertFilter(url, FinishRouter, beegoFinishRouter1, false) mux.InsertFilter(url, FinishRouter, beegoFinishRouter2) mux.Get(url, beegoFilterFunc) @@ -534,7 +534,7 @@ func TestFilterFinishRouterMulti(t *testing.T) { mux := NewControllerRegister() mux.InsertFilter(url, FinishRouter, beegoFinishRouter1, false) - mux.InsertFilter(url, FinishRouter, beegoFinishRouter2) + mux.InsertFilter(url, FinishRouter, beegoFinishRouter2, false) mux.Get(url, beegoFilterFunc)