Skip to content

Commit

Permalink
fix #1473 and add test for #1468 #1474 #1475
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Mar 24, 2020
1 parent 52692b3 commit bb7dfdf
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.vscode
_authortools
/_examples/issue-*/
.directory
node_modules
package-lock.json
Expand Down
2 changes: 1 addition & 1 deletion context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
39 changes: 39 additions & 0 deletions mvc/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit bb7dfdf

Please sign in to comment.