HTTP Header - CORS跨域设置增加多个选项

This commit is contained in:
GoEdgeLab
2023-05-19 16:33:13 +08:00
parent 879e00fda7
commit 7d90a3a77b

View File

@@ -4,14 +4,21 @@ package shared
// HTTPCORSHeaderConfig 参考 https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS // HTTPCORSHeaderConfig 参考 https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
type HTTPCORSHeaderConfig struct { type HTTPCORSHeaderConfig struct {
IsOn bool `yaml:"isOn" json:"isOn"` IsOn bool `yaml:"isOn" json:"isOn"`
AllowMethods []string `yaml:"allowMethods" json:"allowMethods"` // TODO AllowMethods []string `yaml:"allowMethods" json:"allowMethods"`
AllowOrigin string `yaml:"allowOrigin" json:"allowOrigin"` // TODO AllowOrigin string `yaml:"allowOrigin" json:"allowOrigin"` // TODO
AllowCredentials bool `yaml:"allowCredentials" json:"allowCredentials"` // TODO AllowCredentials bool `yaml:"allowCredentials" json:"allowCredentials"` // TODO,实现时需要升级以往的老数据
ExposeHeaders []string `yaml:"exposeHeaders" json:"exposeHeaders"` // TODO ExposeHeaders []string `yaml:"exposeHeaders" json:"exposeHeaders"`
MaxAge int32 `yaml:"maxAge" json:"maxAge"` // TODO MaxAge int32 `yaml:"maxAge" json:"maxAge"`
RequestHeaders []string `yaml:"requestHeaders" json:"requestHeaders"` // TODO RequestHeaders []string `yaml:"requestHeaders" json:"requestHeaders"` // TODO
RequestMethod string `yaml:"requestMethod" json:"requestMethod"` // TODO RequestMethod string `yaml:"requestMethod" json:"requestMethod"`
OptionsMethodOnly bool `yaml:"optionsMethodOnly" json:"optionsMethodOnly"`
}
func NewHTTPCORSHeaderConfig() *HTTPCORSHeaderConfig {
return &HTTPCORSHeaderConfig{
AllowCredentials: true,
}
} }
func (this *HTTPCORSHeaderConfig) Init() error { func (this *HTTPCORSHeaderConfig) Init() error {