2024-06-15 13:56:47 -07:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gorilla/context"
|
|
|
|
"github.com/gorilla/sessions"
|
|
|
|
"github.com/labstack/echo/v4"
|
2024-07-09 17:57:05 -07:00
|
|
|
|
|
|
|
"git.grosinger.net/tgrosinger/saasitone/pkg/session"
|
2024-06-15 13:56:47 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// Session sets the session storage in the request context
|
|
|
|
func Session(store sessions.Store) echo.MiddlewareFunc {
|
|
|
|
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
|
|
|
return func(ctx echo.Context) error {
|
|
|
|
defer context.Clear(ctx.Request())
|
|
|
|
session.Store(ctx, store)
|
|
|
|
return next(ctx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|