From 912abe3272b513ff195e762f8297e751c9b33b73 Mon Sep 17 00:00:00 2001 From: astaxie Date: Mon, 12 Oct 2015 21:26:18 +0800 Subject: [PATCH] fix #1388 --- router.go | 2 +- router_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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: //