Files
ziti/controller/api/cors.go
T
2021-11-30 13:57:35 -05:00

30 lines
639 B
Go

package api
import (
"github.com/gorilla/handlers"
"github.com/openziti/foundation/common/constants"
"net/http"
)
func WrapCorsHandler(innerHandler http.Handler) http.Handler {
corsOpts := []handlers.CORSOption{
handlers.AllowedOrigins([]string{"*"}),
handlers.OptionStatusCode(200),
handlers.AllowedHeaders([]string{
"content-type",
"Accept",
constants.ZitiSession,
}),
handlers.AllowedMethods([]string{
http.MethodGet,
http.MethodHead,
http.MethodPost,
http.MethodPut,
http.MethodPatch,
http.MethodDelete}),
handlers.AllowCredentials(),
}
return handlers.CORS(corsOpts...)(innerHandler)
}