package middleware import ( "lcp/api/binding/http_binding/binding_context" "net/http" ) func Cors() Func { return func(c *binding_context.Context) { method := c.Request.Method c.Header("Access-Control-Allow-Origin", "*") c.Header("Access-Control-Allow-Headers", "Content-Length, Content-Type, AccessToken, X-CSRF-Token, Authorization, Token") c.Header("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE,OPTIONS") c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, "+ "Access-Control-Allow-Headers, Content-Type") c.Header("Access-Control-Allow-Credentials", "true") if method == "OPTIONS" { c.AbortWithStatus(http.StatusOK) } c.Next() } }