1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 03:00:49 +00:00
This commit is contained in:
astaxie 2015-10-12 21:26:18 +08:00
parent 4ba50e5df5
commit 912abe3272
2 changed files with 13 additions and 1 deletions

View File

@ -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 {

View File

@ -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:
//