diff --git a/router.go b/router.go index c0a50988..bb6bb786 100644 --- a/router.go +++ b/router.go @@ -353,7 +353,7 @@ func (p *ControllerRegister) Handler(pattern string, h http.Handler, options ... route.handler = h if len(options) > 0 { if _, ok := options[0].(bool); ok { - pattern = path.Join(pattern, "?:all") + pattern = path.Join(pattern, "?:all(.*)") } } for _, m := range HTTPMETHOD { diff --git a/router_test.go b/router_test.go index c6ec9c92..9598f99c 100644 --- a/router_test.go +++ b/router_test.go @@ -333,6 +333,18 @@ func TestRouterHandler(t *testing.T) { } } +func TestRouterHandlerAll(t *testing.T) { + r, _ := http.NewRequest("POST", "/sayhi/a/b/c", nil) + w := httptest.NewRecorder() + + handler := NewControllerRegister() + handler.Handler("/sayhi", http.HandlerFunc(sayhello), true) + handler.ServeHTTP(w, r) + if w.Body.String() != "sayhello" { + t.Errorf("TestRouterHandler can't run") + } +} + // // Benchmarks NewApp: //