|
|
@ -297,12 +297,14 @@ var ( |
|
|
|
// API settings
|
|
|
|
// API settings
|
|
|
|
API = struct { |
|
|
|
API = struct { |
|
|
|
EnableSwagger bool |
|
|
|
EnableSwagger bool |
|
|
|
|
|
|
|
SwaggerURL string |
|
|
|
MaxResponseItems int |
|
|
|
MaxResponseItems int |
|
|
|
DefaultPagingNum int |
|
|
|
DefaultPagingNum int |
|
|
|
DefaultGitTreesPerPage int |
|
|
|
DefaultGitTreesPerPage int |
|
|
|
DefaultMaxBlobSize int64 |
|
|
|
DefaultMaxBlobSize int64 |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
EnableSwagger: true, |
|
|
|
EnableSwagger: true, |
|
|
|
|
|
|
|
SwaggerURL: "", |
|
|
|
MaxResponseItems: 50, |
|
|
|
MaxResponseItems: 50, |
|
|
|
DefaultPagingNum: 30, |
|
|
|
DefaultPagingNum: 30, |
|
|
|
DefaultGitTreesPerPage: 1000, |
|
|
|
DefaultGitTreesPerPage: 1000, |
|
|
@ -581,17 +583,17 @@ func NewContext() { |
|
|
|
AppURL = strings.TrimRight(AppURL, "/") + "/" |
|
|
|
AppURL = strings.TrimRight(AppURL, "/") + "/" |
|
|
|
|
|
|
|
|
|
|
|
// Check if has app suburl.
|
|
|
|
// Check if has app suburl.
|
|
|
|
url, err := url.Parse(AppURL) |
|
|
|
appURL, err := url.Parse(AppURL) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Fatal("Invalid ROOT_URL '%s': %s", AppURL, err) |
|
|
|
log.Fatal("Invalid ROOT_URL '%s': %s", AppURL, err) |
|
|
|
} |
|
|
|
} |
|
|
|
// Suburl should start with '/' and end without '/', such as '/{subpath}'.
|
|
|
|
// Suburl should start with '/' and end without '/', such as '/{subpath}'.
|
|
|
|
// This value is empty if site does not have sub-url.
|
|
|
|
// This value is empty if site does not have sub-url.
|
|
|
|
AppSubURL = strings.TrimSuffix(url.Path, "/") |
|
|
|
AppSubURL = strings.TrimSuffix(appURL.Path, "/") |
|
|
|
AppSubURLDepth = strings.Count(AppSubURL, "/") |
|
|
|
AppSubURLDepth = strings.Count(AppSubURL, "/") |
|
|
|
// Check if Domain differs from AppURL domain than update it to AppURL's domain
|
|
|
|
// Check if Domain differs from AppURL domain than update it to AppURL's domain
|
|
|
|
// TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8
|
|
|
|
// TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8
|
|
|
|
urlHostname := strings.SplitN(url.Host, ":", 2)[0] |
|
|
|
urlHostname := strings.SplitN(appURL.Host, ":", 2)[0] |
|
|
|
if urlHostname != Domain && net.ParseIP(urlHostname) == nil { |
|
|
|
if urlHostname != Domain && net.ParseIP(urlHostname) == nil { |
|
|
|
Domain = urlHostname |
|
|
|
Domain = urlHostname |
|
|
|
} |
|
|
|
} |
|
|
@ -900,6 +902,10 @@ func NewContext() { |
|
|
|
log.Fatal("Failed to map Metrics settings: %v", err) |
|
|
|
log.Fatal("Failed to map Metrics settings: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u := *appURL |
|
|
|
|
|
|
|
u.Path = path.Join(u.Path, "api", "swagger") |
|
|
|
|
|
|
|
API.SwaggerURL = u.String() |
|
|
|
|
|
|
|
|
|
|
|
newCron() |
|
|
|
newCron() |
|
|
|
newGit() |
|
|
|
newGit() |
|
|
|
|
|
|
|
|
|
|
|