Configure basePathes in an extra function, see #47299-files-serving
@@ -45,31 +45,7 @@ func Load(config *Gateway, log *logrus.Entry) *Gateway {
for idx, server := range config.Server {
configureDomains(server)
-
- if server.BasePath == "" {
- server.BasePath = "/"
- }
- if !strings.HasSuffix(server.BasePath, "/") {
- server.BasePath = server.BasePath + "/"
- }
- if server.Files != nil {
- server.Files.BasePath = path.Join(server.BasePath, server.Files.BasePath)
- if !strings.HasSuffix(server.Files.BasePath, "/") {
- server.Files.BasePath = server.Files.BasePath + "/"
- }
- }
- if server.Spa != nil {
- server.Spa.BasePath = path.Join(server.BasePath, server.Spa.BasePath) + "/"
- if !strings.HasSuffix(server.Spa.BasePath, "/") {
- server.Spa.BasePath = server.Spa.BasePath + "/"
- }
- }
- if server.API != nil {
- server.API.BasePath = path.Join(server.BasePath, server.API.BasePath) + "/"
- if !strings.HasSuffix(server.API.BasePath, "/") {
- server.API.BasePath = server.API.BasePath + "/"
- }
- }
+ configureBasePathes(server)
if server.API == nil {
continue
@@ -144,6 +120,33 @@ func Load(config *Gateway, log *logrus.Entry) *Gateway {
return config
}
+func configureBasePathes(server *Server) {
+ if server.BasePath == "" {
+ server.BasePath = "/"
+ }
+ if !strings.HasSuffix(server.BasePath, "/") {
+ server.BasePath = server.BasePath + "/"
+ }
+ if server.Files != nil {
+ server.Files.BasePath = path.Join(server.BasePath, server.Files.BasePath)
+ if !strings.HasSuffix(server.Files.BasePath, "/") {
+ server.Files.BasePath = server.Files.BasePath + "/"
+ }
+ }
+ if server.Spa != nil {
+ server.Spa.BasePath = path.Join(server.BasePath, server.Spa.BasePath) + "/"
+ if !strings.HasSuffix(server.Spa.BasePath, "/") {
+ server.Spa.BasePath = server.Spa.BasePath + "/"
+ }
+ }
+ if server.API != nil {
+ server.API.BasePath = path.Join(server.BasePath, server.API.BasePath) + "/"
+ if !strings.HasSuffix(server.API.BasePath, "/") {
+ server.API.BasePath = server.API.BasePath + "/"
+ }
+ }
+}
+
// configureDomains is a fallback configuration which ensures
// the request multiplexer is working properly.
func configureDomains(server *Server) {
