-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.go
32 lines (30 loc) · 1.59 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package headers
// Config declares headers service configuration.
type Config struct {
// CORS settings.
CORS *CORSConfig `mapstructure:"cors"`
// Request headers to add to every payload send to PHP.
Request map[string]string `mapstructure:"request"`
// Response headers to add to every payload generated by PHP.
Response map[string]string `mapstructure:"response"`
}
// CORSConfig headers configuration.
type CORSConfig struct {
// AllowedOrigin: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
AllowedOrigin string `mapstructure:"allowed_origin"`
AllowedOriginRegex string `mapstructure:"allowed_origin_regex"`
// AllowedHeaders: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
AllowedHeaders string `mapstructure:"allowed_headers"`
// AllowedMethods: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
AllowedMethods string `mapstructure:"allowed_methods"`
// AllowCredentials https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
AllowCredentials bool `mapstructure:"allow_credentials"`
// ExposeHeaders: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
ExposedHeaders string `mapstructure:"exposed_headers"`
// MaxAge of CORS headers in seconds/
MaxAge int `mapstructure:"max_age"`
// Status code to use for successful OPTIONS requests. Default value is http.StatusOK (200).
OptionsSuccessStatus int `mapstructure:"options_success_status"`
// Debug CORS requests
Debug bool `mapstructure:"debug"`
}