This commit is contained in:
2017-06-17 01:12:28 +02:00
parent 4e02a8f4bc
commit a9f88db566
9 changed files with 154 additions and 154 deletions

View File

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