mirror of
https://github.com/openziti/ziti.git
synced 2026-09-20 17:43:28 +00:00
6625084569
- use xweb for run - use xweb for api tests - use time.ParseDuration for edge configuration - use CORS defaults in Client/Management API handlers
30 lines
640 B
Go
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)
|
|
}
|