Library/routes/cors.go

17 lines
540 B
Go
Raw Permalink Normal View History

2017-11-08 15:59:48 +00:00
package routes
import (
"github.com/labstack/echo"
"net/http"
)
// SetCORSHeader sets relevant CORS headers for Cross-Site-Requests to the api
2017-11-08 16:12:05 +00:00
func SetCORSHeader(c echo.Context) error {
2017-11-08 15:59:48 +00:00
res := c.Response()
res.Header().Set("Access-Control-Allow-Origin", "*")
res.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE")
res.Header().Set("Access-Control-Allow-Headers", "authorization,content-type")
res.Header().Set("Access-Control-Expose-Headers", "authorization,content-type")
return c.String(http.StatusOK, "")
2017-11-08 16:12:05 +00:00
}