1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00
Former-commit-id: 1e2c7185fc3c536ceb8b269c75b9a2c19323960b
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-09-07 05:57:35 +03:00
parent 6fa75f7b51
commit da73c1817f
6 changed files with 30 additions and 7 deletions

View File

@@ -166,3 +166,20 @@ func TestControllerHandle(t *testing.T) {
e.GET("/hi/param/empty/input/with/ctx/value").Expect().Status(httptest.StatusOK).
Body().Equal("empty in but served with ctx.Params.Get('param2')= value == id == value")
}
type testControllerHandleWithDynamicPathPrefix struct {
Ctx iris.Context
}
func (c *testControllerHandleWithDynamicPathPrefix) GetBy(id string) string {
params := c.Ctx.Params()
return params.Get("model") + params.Get("action") + id
}
func TestControllerHandleWithDynamicPathPrefix(t *testing.T) {
app := iris.New()
New(app.Party("/api/data/{model:string}/{action:string}")).Handle(new(testControllerHandleWithDynamicPathPrefix))
e := httptest.New(t, app)
e.GET("/api/data/mymodel/myaction/myid").Expect().Status(httptest.StatusOK).
Body().Equal("mymodelmyactionmyid")
}