mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
fix https://github.com/kataras/iris/issues/1473 and add test for https://github.com/kataras/iris/issues/1468 https://github.com/kataras/iris/pull/1474 https://github.com/kataras/iris/pull/1475
Former-commit-id: 3e7d927761a5d5559b65ea3f91b94e3dc523a187
This commit is contained in:
parent
0d3770380f
commit
a694266c63
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
.vscode
|
||||
_authortools
|
||||
/_examples/issue-*/
|
||||
.directory
|
||||
node_modules
|
||||
package-lock.json
|
||||
|
|
|
@ -1382,8 +1382,8 @@ func (ctx *context) Next() { // or context.Next(ctx)
|
|||
// it sends a Status Not Found (404) to the client and it stops the execution.
|
||||
func (ctx *context) NextOr(handlers ...Handler) bool {
|
||||
if next := ctx.NextHandler(); next != nil {
|
||||
next(ctx)
|
||||
ctx.Skip() // skip this handler from the chain.
|
||||
next(ctx)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -585,3 +585,42 @@ func TestControllerRequestScopedDependencies(t *testing.T) {
|
|||
})
|
||||
e.GET("/custom/context").Expect().Status(httptest.StatusOK).Body().Equal("test")
|
||||
}
|
||||
|
||||
type (
|
||||
testServiceDoSomething struct{}
|
||||
|
||||
TestControllerAsDeepDep struct {
|
||||
Ctx iris.Context
|
||||
Service *testServiceDoSomething
|
||||
}
|
||||
|
||||
FooController struct {
|
||||
TestControllerAsDeepDep
|
||||
}
|
||||
|
||||
BarController struct {
|
||||
FooController
|
||||
}
|
||||
|
||||
FinalController struct {
|
||||
BarController
|
||||
}
|
||||
)
|
||||
|
||||
func (s *testServiceDoSomething) DoSomething(ctx iris.Context) {
|
||||
ctx.WriteString("foo bar")
|
||||
}
|
||||
|
||||
func (c *FinalController) GetSomething() {
|
||||
c.Service.DoSomething(c.Ctx)
|
||||
}
|
||||
|
||||
func TestControllersInsideControllerDeep(t *testing.T) {
|
||||
app := iris.New()
|
||||
m := New(app)
|
||||
m.Register(new(testServiceDoSomething))
|
||||
m.Handle(new(FinalController))
|
||||
|
||||
e := httptest.New(t, app)
|
||||
e.GET("/something").Expect().Status(httptest.StatusOK).Body().Equal("foo bar")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user