mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 02:17:05 +00:00
Update sessions/sessiondb/badger to its latest version and SessionController is able to initialize itself if session manager is not provided by the caller-dev.
Changes:
Update the badger database using transactions, as supported from yesterday via: 06242925c2
Add a custom `OnActivate` via mvc/activator/activate_listener.go, this can be used to perform any custom actions when the app registers the supported Controllers. See mvc/session_controller.go for the excellent use case.
errors.Reporter.AddErr returns true if the error is added to the stack, otherwise false
Former-commit-id: c896a2d186a4315643f3c5fdb4325f7ee48a9e0a
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/context"
|
||||
"github.com/kataras/iris/mvc"
|
||||
"github.com/kataras/iris/mvc/activator"
|
||||
|
||||
"github.com/kataras/iris/core/router"
|
||||
"github.com/kataras/iris/httptest"
|
||||
@@ -493,3 +494,33 @@ func TestControllerRelPathFromFunc(t *testing.T) {
|
||||
e.GET("/anything/here").Expect().Status(httptest.StatusOK).
|
||||
Body().Equal("GET:/anything/here")
|
||||
}
|
||||
|
||||
type testControllerActivateListener struct {
|
||||
mvc.Controller
|
||||
|
||||
TitlePointer *testBindType
|
||||
}
|
||||
|
||||
func (c *testControllerActivateListener) OnActivate(p *activator.ActivatePayload) {
|
||||
p.EnsureBindValue(&testBindType{
|
||||
title: "default title",
|
||||
})
|
||||
}
|
||||
|
||||
func (c *testControllerActivateListener) Get() {
|
||||
c.Text = c.TitlePointer.title
|
||||
}
|
||||
|
||||
func TestControllerActivateListener(t *testing.T) {
|
||||
app := iris.New()
|
||||
app.Controller("/", new(testControllerActivateListener))
|
||||
app.Controller("/manual", new(testControllerActivateListener), &testBindType{
|
||||
title: "my title",
|
||||
})
|
||||
|
||||
e := httptest.New(t, app)
|
||||
e.GET("/").Expect().Status(httptest.StatusOK).
|
||||
Body().Equal("default title")
|
||||
e.GET("/manual").Expect().Status(httptest.StatusOK).
|
||||
Body().Equal("my title")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user