77f9998393
CI / docker (push) Successful in 3m13s
引入用户端对话/生图与管理端 Provider 配置,统一 invoke 编排、Gateway、请求日志与模型管理;前端按设计规范拆分布局,Go module 更名为 github.com/rose_cat707/Atlas;生图长任务 SSE 推送;管理端登录防爆破;协议与服务类型联动;Replicate 模型同步修复;用户端创作台 UI 重构;管理端创作历史替代请求日志。 Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
794 B
Go
41 lines
794 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const sessionCookie = "Atlas-Session"
|
|
|
|
func (s *Server) sessionMiddleware() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
sid, err := c.Cookie(sessionCookie)
|
|
if err != nil || sid == "" {
|
|
sid = uuid.New().String()
|
|
http.SetCookie(c.Writer, &http.Cookie{
|
|
Name: sessionCookie,
|
|
Value: sid,
|
|
Path: "/",
|
|
MaxAge: int((30 * 24 * time.Hour).Seconds()),
|
|
HttpOnly: true,
|
|
SameSite: http.SameSiteLaxMode,
|
|
})
|
|
}
|
|
_ = s.app.Store.UpsertSession(c.Request.Context(), sid)
|
|
c.Set("session_id", sid)
|
|
c.Next()
|
|
}
|
|
}
|
|
|
|
func sessionID(c *gin.Context) string {
|
|
if v, ok := c.Get("session_id"); ok {
|
|
if s, ok := v.(string); ok {
|
|
return s
|
|
}
|
|
}
|
|
return ""
|
|
}
|