1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-01 03:30:17 +00:00

fix autorouter params

This commit is contained in:
astaxie
2013-12-18 10:00:52 +08:00
parent 00065f2b08
commit 9edf3143e1
2 changed files with 24 additions and 0 deletions

View File

@ -19,6 +19,10 @@ func (this *TestController) List() {
this.Ctx.Output.Body([]byte("i am list"))
}
func (this *TestController) Params() {
this.Ctx.Output.Body([]byte(this.Ctx.Input.Params["0"] + this.Ctx.Input.Params["1"] + this.Ctx.Input.Params["2"]))
}
func (this *TestController) Myext() {
this.Ctx.Output.Body([]byte(this.Ctx.Input.Param(":ext")))
}
@ -89,6 +93,18 @@ func TestAutoFunc(t *testing.T) {
}
}
func TestAutoFuncParams(t *testing.T) {
r, _ := http.NewRequest("GET", "/test/params/2009/11/12", nil)
w := httptest.NewRecorder()
handler := NewControllerRegistor()
handler.AddAuto(&TestController{})
handler.ServeHTTP(w, r)
if w.Body.String() != "20091112" {
t.Errorf("user define func can't run")
}
}
func TestAutoExtFunc(t *testing.T) {
r, _ := http.NewRequest("GET", "/test/myext.json", nil)
w := httptest.NewRecorder()