@@ -297,12 +297,14 @@ var (
297297 // API settings
298298 API = struct {
299299 EnableSwagger bool
300+ SwaggerURL string
300301 MaxResponseItems int
301302 DefaultPagingNum int
302303 DefaultGitTreesPerPage int
303304 DefaultMaxBlobSize int64
304305 }{
305306 EnableSwagger : true ,
307+ SwaggerURL : "" ,
306308 MaxResponseItems : 50 ,
307309 DefaultPagingNum : 30 ,
308310 DefaultGitTreesPerPage : 1000 ,
@@ -581,17 +583,17 @@ func NewContext() {
581583 AppURL = strings .TrimRight (AppURL , "/" ) + "/"
582584
583585 // Check if has app suburl.
584- url , err := url .Parse (AppURL )
586+ appURL , err := url .Parse (AppURL )
585587 if err != nil {
586588 log .Fatal ("Invalid ROOT_URL '%s': %s" , AppURL , err )
587589 }
588590 // Suburl should start with '/' and end without '/', such as '/{subpath}'.
589591 // This value is empty if site does not have sub-url.
590- AppSubURL = strings .TrimSuffix (url .Path , "/" )
592+ AppSubURL = strings .TrimSuffix (appURL .Path , "/" )
591593 AppSubURLDepth = strings .Count (AppSubURL , "/" )
592594 // Check if Domain differs from AppURL domain than update it to AppURL's domain
593595 // TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8
594- urlHostname := strings .SplitN (url .Host , ":" , 2 )[0 ]
596+ urlHostname := strings .SplitN (appURL .Host , ":" , 2 )[0 ]
595597 if urlHostname != Domain && net .ParseIP (urlHostname ) == nil {
596598 Domain = urlHostname
597599 }
@@ -900,6 +902,10 @@ func NewContext() {
900902 log .Fatal ("Failed to map Metrics settings: %v" , err )
901903 }
902904
905+ u := * appURL
906+ u .Path = path .Join (u .Path , "api" , "swagger" )
907+ API .SwaggerURL = u .String ()
908+
903909 newCron ()
904910 newGit ()
905911
0 commit comments