mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
add support for mvc and hero dynamic dependencies to understand the error type as a second output value as requested at: https://github.com/kataras/iris/issues/1187
Former-commit-id: 49e29c06aaaa22743354981342c29fc9d5953d0e
This commit is contained in:
@@ -272,11 +272,22 @@ type testControllerBindDeep struct {
|
||||
testControllerBindStruct
|
||||
}
|
||||
|
||||
func (t *testControllerBindDeep) BeforeActivation(b BeforeActivation) {
|
||||
b.Dependencies().Add(func(ctx iris.Context) (v testCustomStruct, err error) {
|
||||
err = ctx.ReadJSON(&v)
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
func (t *testControllerBindDeep) Get() {
|
||||
// t.testControllerBindStruct.Get()
|
||||
t.Ctx.Writef(t.TitlePointer.title + t.TitleValue.title + t.Other)
|
||||
}
|
||||
|
||||
func (t *testControllerBindDeep) Post(v testCustomStruct) string {
|
||||
return v.Name
|
||||
}
|
||||
|
||||
func TestControllerDependencies(t *testing.T) {
|
||||
app := iris.New()
|
||||
// app.Logger().SetLevel("debug")
|
||||
@@ -299,6 +310,12 @@ func TestControllerDependencies(t *testing.T) {
|
||||
|
||||
e.GET("/deep").Expect().Status(iris.StatusOK).
|
||||
Body().Equal(expected)
|
||||
|
||||
e.POST("/deep").WithJSON(iris.Map{"name": "kataras"}).Expect().Status(iris.StatusOK).
|
||||
Body().Equal("kataras")
|
||||
|
||||
e.POST("/deep").Expect().Status(iris.StatusBadRequest).
|
||||
Body().Equal("unexpected end of JSON input")
|
||||
}
|
||||
|
||||
type testCtrl0 struct {
|
||||
|
||||
Reference in New Issue
Block a user