MCPcopy Index your code
hub / github.com/SMNETSTUDIO/Groq2API / Cors

Function Cors

middlewares/cors.go:5–17  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

3import "github.com/gin-gonic/gin"
4
5func Cors(c *gin.Context) {
6 c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
7 c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
8 c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
9 c.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, Accept")
10 c.Writer.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
11 // 如果是OPTIONS请求,直接返回
12 if c.Request.Method == "OPTIONS" {
13 c.AbortWithStatus(204)
14 return
15 }
16 c.Next()
17}

Callers

nothing calls this directly

Calls 2

SetMethod · 0.80
HeaderMethod · 0.80

Tested by

no test coverage detected