| 155 | } |
| 156 | |
| 157 | func 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 | |
| 174 | type Response struct { |
| 175 | Tracks []string `json:"tracks"` |