28e53d90fc
- 统一 OpenAI 兼容 /v1 中继 + 渠道/额度/令牌/流水 - 各领域包:relay 模型网关、model 数据层、controller 管理 API
24 lines
525 B
Go
24 lines
525 B
Go
package middleware
|
|
|
|
import (
|
|
"github.com/QuantumNous/new-api/common"
|
|
"github.com/gin-contrib/cors"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func CORS() gin.HandlerFunc {
|
|
config := cors.DefaultConfig()
|
|
config.AllowAllOrigins = true
|
|
config.AllowCredentials = true
|
|
config.AllowMethods = []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}
|
|
config.AllowHeaders = []string{"*"}
|
|
return cors.New(config)
|
|
}
|
|
|
|
func Version() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
c.Header("X-New-Api-Version", common.Version)
|
|
c.Next()
|
|
}
|
|
}
|