Upgraded to latest aero version
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user