1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 18:37:05 +00:00

split of the mvc and the new hero package is completed, now handlers with input and output binding feature is a different feature than the mvc, however the mvc controller's methods can use the hero dependency injection as before (v10+)

Former-commit-id: d67f5a5ed9033286bcc4c04f6be612823cba2a57
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-12-25 20:57:04 +02:00
parent 46505f62db
commit 2ab1456414
33 changed files with 166 additions and 2067 deletions

View File

@@ -10,6 +10,23 @@ import (
. "github.com/kataras/iris/mvc"
)
// service
type (
// these TestService and TestServiceImpl could be in lowercase, unexported
// but the `Say` method should be exported however we have those exported
// because of the controller handler test.
TestService interface {
Say(string) string
}
TestServiceImpl struct {
prefix string
}
)
func (s *TestServiceImpl) Say(message string) string {
return s.prefix + " " + message
}
type testControllerHandle struct {
Ctx context.Context
Service TestService
@@ -53,9 +70,9 @@ func (c *testControllerHandle) HiParamEmptyInputBy() string {
func TestControllerHandle(t *testing.T) {
app := iris.New()
m := NewEngine()
m.Dependencies.Add(&TestServiceImpl{prefix: "service:"})
m.Controller(app, new(testControllerHandle))
m := New(app)
m.AddDependencies(&TestServiceImpl{prefix: "service:"})
m.Register(new(testControllerHandle))
e := httptest.New(t, app)