Files
ziti/controller/server/cors.go
T
Andrew Martinez 6625084569 use xweb for Edge Client and Management APIs
- use xweb for run
- use xweb for api tests
- use time.ParseDuration for edge configuration
- use CORS defaults in Client/Management API handlers
2021-05-06 16:45:48 -04:00

30 lines
640 B
Go

package server
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)
}