Moved server packages to a separate folder

This commit is contained in:
2019-11-18 18:39:59 +09:00
parent db366360c7
commit f3c14a4ed6
37 changed files with 28 additions and 23 deletions

View 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
}
}