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