mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 15:13:30 +00:00
17 lines
382 B
Go
17 lines
382 B
Go
package middleware
|
|
|
|
import (
|
|
"github.com/gorilla/sessions"
|
|
"github.com/labstack/echo/v5"
|
|
)
|
|
|
|
func SessionMiddleware() echo.MiddlewareFunc {
|
|
store := sessions.NewCookieStore([]byte("secret")) // TODO: 从配置中获取密钥
|
|
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
|
return func(c *echo.Context) error {
|
|
c.Set("_session_store", store)
|
|
return next(c)
|
|
}
|
|
}
|
|
}
|