This commit is contained in:
2026-05-12 01:13:01 +02:00
commit bf304e17c9
46 changed files with 4358 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
package middleware
import (
"prestaproxy/internal/prestashop/cookie"
"github.com/labstack/echo/v4"
)
const sessionContextKey = "prestashop_session"
func SetSession(c echo.Context, session *cookie.SessionContext) {
if session == nil {
session = defaultSession()
}
c.Set(sessionContextKey, session)
}
func GetSession(c echo.Context) *cookie.SessionContext {
if value := c.Get(sessionContextKey); value != nil {
if session, ok := value.(*cookie.SessionContext); ok {
if session != nil {
return session
}
}
}
return defaultSession()
}
func defaultSession() *cookie.SessionContext {
return &cookie.SessionContext{
Values: map[string]string{},
ParseStatus: cookie.ParseStatusAnonymous,
}
}