Moved server packages to a separate folder
This commit is contained in:
18
server/middleware/Session.go
Normal file
18
server/middleware/Session.go
Normal file
@ -0,0 +1,18 @@
|
||||
package middleware
|
||||
|
||||
import "github.com/aerogo/aero"
|
||||
|
||||
// Session middleware saves an existing session if it has been modified.
|
||||
func Session(next aero.Handler) aero.Handler {
|
||||
return func(ctx aero.Context) error {
|
||||
// Handle the request first
|
||||
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())
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user