Cleanup
This commit is contained in:
16
middleware/Session.go
Normal file
16
middleware/Session.go
Normal 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())
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user