Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CORSService = dependency.Service{ Name: "cors", ConfigFunc: func(set dependency.FlagSet) { set.StringSlice( "cors-allowed-headers", []string{ ":authority", ":method", ":path", ":scheme", "Accept", "Accept-Encoding", "Accept-Language", "Authorization", "Origin", "Referer", "Sec-Fetch-Mode", "Sec-Fetch-Site", "User-Agent", "X-Forwarded-For", "X-Real-IP", "X-Forwarded-Proto", "X-Requested-With", }, "The headers allowed to be passed from a CORS request", ) set.StringSlice( "cors-allowed-methods", []string{ http.MethodGet, http.MethodHead, http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete, http.MethodConnect, http.MethodOptions, http.MethodTrace, }, "The headers to allow cross origin requests with", ) set.StringSlice( "cors-allowed-origins", []string{ "localhost", }, "The origins to allow requests from", ) set.Bool( "cors-allow-credentials", true, "Whether to allow credentials over cross origin", ) }, Constructor: fx.Annotated{ Group: "middleware", Target: NewCORS, }, }
CORSService allows the the cors middleware to be registered with an application
View Source
var Module = fx.Provide( fx.Annotated{ Group: "middleware", Target: func(logger logging.PrintLogger) mux.MiddlewareFunc { return handlers.RecoveryHandler( handlers.RecoveryLogger(logger), ) }, }, fx.Annotated{ Group: "middleware", Target: func() mux.MiddlewareFunc { return gziphandler.GzipHandler }, }, fx.Annotated{ Group: "middleware", Target: nrgorilla.Middleware, }, )
Module allows the default middlewares to be registered to an app
Functions ¶
func NewCORS ¶
func NewCORS(config dependency.ConfigGetter) mux.MiddlewareFunc
NewCORS creates a new cors middleware configured from the app
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.