Upgraded to latest aero version

This commit is contained in:
2019-06-01 13:55:49 +09:00
parent ae591e5e7e
commit 28db818c37
196 changed files with 645 additions and 593 deletions

View File

@ -3,14 +3,16 @@ package middleware
import "github.com/aerogo/aero"
// Session middleware saves an existing session if it has been modified.
func Session() aero.Middleware {
return func(ctx *aero.Context, next func()) {
func Session(next aero.Handler) aero.Handler {
return func(ctx aero.Context) error {
// Handle the request first
next()
err := next(ctx)
// Update session if it has been modified
if ctx.HasSession() && ctx.Session().Modified() {
ctx.App.Sessions.Store.Set(ctx.Session().ID(), ctx.Session())
_ = ctx.App().Sessions.Store.Set(ctx.Session().ID(), ctx.Session())
}
return err
}
}