Documentation ¶
Index ¶
Constants ¶
View Source
const (
CorsPropertiesPrefix = "security.cors"
)
Variables ¶
View Source
var Module = &bootstrap.Module{ Name: "CORS", Precedence: web.MinWebPrecedence + 1, PriorityOptions: []fx.Option{ fx.Provide(BindCorsProperties), web.FxCustomizerProviders(newCustomizer), }, }
Functions ¶
func New ¶
func New(options Options) gin.HandlerFunc
New creates a new CORS Gin middleware with the provided options.
Types ¶
type CorsProperties ¶
type CorsProperties struct { Enabled bool `json:"enabled"` // Comma-separated list of origins to allow. '*' allows all origins. Default to '*' AllowedOriginsStr string `json:"allowed-origins"` // Comma-separated list of methods to allow. '*' allows all methods. Default to '*' AllowedMethodsStr string `json:"allowed-methods"` // Comma-separated list of headers to allow in a request. '*' allows all headers. Default to '*' AllowedHeadersStr string `json:"allowed-headers"` // Comma-separated list of headers to include in a response. ExposedHeadersStr string `json:"exposed-headers"` // Whether credentials are supported. When not set, credentials are not supported. AllowCredentials bool `json:"allow-credentials"` // How long the response from a pre-flight request can be cached by clients. // If a duration suffix is not specified, seconds will be used. MaxAge utils.Duration `json:"max-age"` }
func BindCorsProperties ¶
func BindCorsProperties(ctx *bootstrap.ApplicationContext) CorsProperties
BindCorsProperties create and bind a ServerProperties using default prefix
func NewCorsProperties ¶
func NewCorsProperties() *CorsProperties
NewCorsProperties create a ServerProperties with default values
func (CorsProperties) AllowedHeaders ¶
func (p CorsProperties) AllowedHeaders() []string
func (CorsProperties) AllowedMethods ¶
func (p CorsProperties) AllowedMethods() []string
func (CorsProperties) AllowedOrigins ¶
func (p CorsProperties) AllowedOrigins() []string
func (CorsProperties) ExposedHeaders ¶
func (p CorsProperties) ExposedHeaders() []string
type Customizer ¶
type Customizer struct {
// contains filtered or unexported fields
}
Customizer implements web.Customizer
Click to show internal directories.
Click to hide internal directories.