MCPcopy Create free account
hub / github.com/deepch/RTSPtoWebRTC / CORSMiddleware

Function CORSMiddleware

http.go:157–172  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

155}
156
157func CORSMiddleware() gin.HandlerFunc {
158 return func(c *gin.Context) {
159 c.Header("Access-Control-Allow-Origin", "*")
160 c.Header("Access-Control-Allow-Credentials", "true")
161 c.Header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization, x-access-token")
162 c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Cache-Control, Content-Language, Content-Type")
163 c.Header("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT")
164
165 if c.Request.Method == "OPTIONS" {
166 c.AbortWithStatus(http.StatusNoContent)
167 return
168 }
169
170 c.Next()
171 }
172}
173
174type Response struct {
175 Tracks []string `json:"tracks"`

Callers 1

serveHTTPFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected