Documentation
¶
Index ¶
- type Cors
- func (c *Cors) Clone() internal.Configurable
- func (c *Cors) Get() interface{}
- func (c *Cors) Set(data interface{})
- func (c *Cors) Validate() error
- func (c *Cors) WithAllowCredentials(allowCredentials bool) *Cors
- func (c *Cors) WithAllowedAllMethods(allowedAllMethods bool) *Cors
- func (c *Cors) WithAllowedAllOrigins(allowedAllOrigins bool) *Cors
- func (c *Cors) WithAllowedHeaders(allowedHeaders []string) *Cors
- func (c *Cors) WithAllowedMethods(allowedMethods []string) *Cors
- func (c *Cors) WithAllowedOrigins(allowedOrigins []string) *Cors
- func (c *Cors) WithEnabled(enabled bool) *Cors
- func (c *Cors) WithExposedHeaders(exposedHeaders []string) *Cors
- func (c *Cors) WithMaxAge(maxAge string) *Cors
- func (c *Cors) WithModuleName(moduleName string) *Cors
- func (c *Cors) WithOptionsResponseCode(optionsResponseCode int) *Cors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cors ¶
type Cors struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled" json:"enabled"` // 是否启用CORS
AllowedOrigins []string `mapstructure:"allowed-origins" yaml:"allowed-origins" json:"allowedOrigins" validate:"dive,required"` // 允许的来源
AllowedMethods []string `mapstructure:"allowed-methods" yaml:"allowed-methods" json:"allowedMethods" validate:"dive,required"` // 允许的方法
AllowedHeaders []string `mapstructure:"allowed-headers" yaml:"allowed-headers" json:"allowedHeaders" validate:"dive,required"` // 允许的头部
MaxAge string `mapstructure:"max-age" yaml:"max-age" json:"maxAge" validate:"required"` // 最大缓存时间
AllowedAllOrigins bool `mapstructure:"allowed-all-origins" yaml:"allowed-all-origins" json:"allowedAllOrigins"` // 是否允许所有来源
AllowedAllMethods bool `mapstructure:"allowed-all-methods" yaml:"allowed-all-methods" json:"allowedAllMethods"` // 是否允许所有方法
ExposedHeaders []string `mapstructure:"exposed-headers" yaml:"exposed-headers" json:"exposedHeaders"` // 暴露的头部
AllowCredentials bool `mapstructure:"allow-credentials" yaml:"allow-credentials" json:"allowCredentials"` // 允许凭证
OptionsResponseCode int `mapstructure:"options-response-code" yaml:"options-response-code" json:"optionsResponseCode"` // Options响应Code
ModuleName string `mapstructure:"module-name" yaml:"module-name" json:"moduleName"` // 模块名称
}
Cors 跨域资源共享配置
func (*Cors) WithAllowCredentials ¶
WithAllowCredentials 设置是否允许凭证
func (*Cors) WithAllowedAllMethods ¶
WithAllowedAllMethods 设置是否允许所有方法
func (*Cors) WithAllowedAllOrigins ¶
WithAllowedAllOrigins 设置是否允许所有来源
func (*Cors) WithAllowedHeaders ¶
WithAllowedHeaders 设置允许的头部
func (*Cors) WithAllowedMethods ¶
WithAllowedMethods 设置允许的方法
func (*Cors) WithAllowedOrigins ¶
WithAllowedOrigins 设置允许的来源
func (*Cors) WithExposedHeaders ¶
WithExposedHeaders 设置暴露的头部
func (*Cors) WithModuleName ¶
WithModuleName 设置模块名称
func (*Cors) WithOptionsResponseCode ¶
WithOptionsResponseCode 设置Options响应码
Click to show internal directories.
Click to hide internal directories.