This commit is contained in:
2017-06-17 01:25:02 +02:00
parent a9f88db566
commit 88614d412b
12 changed files with 18 additions and 18 deletions

16
middleware/Session.go Normal file
View File

@ -0,0 +1,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()) {
// 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())
}
}
}