1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00
Former-commit-id: d93af027428259c857c7a5ddf6e21cfd0b09b470
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-06-14 08:44:41 +03:00
parent ed5964716b
commit 4afef007a4
2 changed files with 31 additions and 2 deletions

View File

@@ -469,12 +469,21 @@ type testControllerActivateListener struct {
func (c *testControllerActivateListener) BeforeActivation(b BeforeActivation) {
b.Dependencies().Register(&testBindType{title: "overrides the dependency but not the field"}) // overrides the `Register` previous calls.
// b.Handle("POST", "/me/tos-read", "MeTOSRead")
// b.Handle("GET", "/me/tos-read", "MeTOSRead")
// OR:
b.HandleMany("GET POST", "/me/tos-read", "MeTOSRead")
}
func (c *testControllerActivateListener) Get() string {
return c.TitlePointer.title
}
func (c *testControllerActivateListener) MeTOSRead() string {
return "MeTOSRead"
}
func TestControllerActivateListener(t *testing.T) {
app := iris.New()
New(app).Handle(new(testControllerActivateListener))
@@ -493,6 +502,11 @@ func TestControllerActivateListener(t *testing.T) {
e := httptest.New(t, app)
e.GET("/").Expect().Status(iris.StatusOK).
Body().Equal("overrides the dependency but not the field")
e.GET("/me/tos-read").Expect().Status(iris.StatusOK).
Body().Equal("MeTOSRead")
e.POST("/me/tos-read").Expect().Status(iris.StatusOK).
Body().Equal("MeTOSRead")
e.GET("/manual").Expect().Status(iris.StatusOK).
Body().Equal("overrides the dependency but not the field")
e.GET("/manual2").Expect().Status(iris.StatusOK).