diff options
author | Unknwon <u@gogs.io> | 2017-01-28 19:59:17 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-01-28 19:59:17 -0500 |
commit | 5e01ecbc0528488427ee455578acbe7ff92efcfe (patch) | |
tree | 5a1ec8467ce931e04a28bb079dd24e8180512b6f /modules/setting/setting.go | |
parent | c98aa0e8950393ac43dc66e8de85973d9cd029ef (diff) |
Able to set custom Access-Control-Allow-Origin header (#3987)
Added new config option '[http] ACCESS_CONTROL_ALLOW_ORIGIN'.
Diffstat (limited to 'modules/setting/setting.go')
-rw-r--r-- | modules/setting/setting.go | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 8e4b3cfa..3b3aa69a 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -34,10 +34,10 @@ import ( type Scheme string const ( - HTTP Scheme = "http" - HTTPS Scheme = "https" - FCGI Scheme = "fcgi" - UNIX_SOCKET Scheme = "unix" + SCHEME_HTTP Scheme = "http" + SCHEME_HTTPS Scheme = "https" + SCHEME_FCGI Scheme = "fcgi" + SCHEME_UNIX_SOCKET Scheme = "unix" ) type LandingPage string @@ -74,6 +74,10 @@ var ( LandingPageURL LandingPage UnixSocketPermission uint32 + HTTP struct { + AccessControlAllowOrigin string + } + SSH struct { Disabled bool `ini:"DISABLE_SSH"` StartBuiltinServer bool `ini:"START_SSH_SERVER"` @@ -388,15 +392,15 @@ func NewContext() { AppSubUrl = strings.TrimSuffix(url.Path, "/") AppSubUrlDepth = strings.Count(AppSubUrl, "/") - Protocol = HTTP + Protocol = SCHEME_HTTP if sec.Key("PROTOCOL").String() == "https" { - Protocol = HTTPS + Protocol = SCHEME_HTTPS CertFile = sec.Key("CERT_FILE").String() KeyFile = sec.Key("KEY_FILE").String() } else if sec.Key("PROTOCOL").String() == "fcgi" { - Protocol = FCGI + Protocol = SCHEME_FCGI } else if sec.Key("PROTOCOL").String() == "unix" { - Protocol = UNIX_SOCKET + Protocol = SCHEME_UNIX_SOCKET UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666") UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32) if err != nil || UnixSocketPermissionParsed > 0777 { @@ -557,7 +561,9 @@ func NewContext() { } } - if err = Cfg.Section("ui").MapTo(&UI); err != nil { + if err = Cfg.Section("http").MapTo(&HTTP); err != nil { + log.Fatal(4, "Fail to map HTTP settings: %v", err) + } else if err = Cfg.Section("ui").MapTo(&UI); err != nil { log.Fatal(4, "Fail to map UI settings: %v", err) } else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil { log.Fatal(4, "Fail to map Markdown settings: %v", err) |