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:
@ -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()
|
||||
|
Reference in New Issue
Block a user