mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-10 01:10:27 +08:00
HTTP Header - CORS跨域设置增加多个选项
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user