Skip to content

Commit

Permalink
feat(swagger): allow swagger port configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
hbollon committed Oct 26, 2021
1 parent 2d0845a commit a2b6715
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions config/config.go
Expand Up @@ -98,9 +98,10 @@ type GitlabConfig struct {

// WebConfig stores the UI interface parameters
type WebConfig struct {
Port uint16 `short:"p" long:"port" env:"TERRABOARD_PORT" yaml:"port" description:"Port to listen on." default:"8080"`
BaseURL string `long:"base-url" env:"TERRABOARD_BASE_URL" yaml:"base-url" description:"Base URL." default:"/"`
LogoutURL string `long:"logout-url" env:"TERRABOARD_LOGOUT_URL" yaml:"logout-url" description:"Logout URL."`
Port uint16 `short:"p" long:"port" env:"TERRABOARD_PORT" yaml:"port" description:"Port to listen on." default:"8080"`
SwaggerPort uint16 `long:"swagger-port" env:"TERRABOARD_SWAGGER_PORT" yaml:"swagger-port" description:"Port for swagger to listen on." default:"8081"`
BaseURL string `long:"base-url" env:"TERRABOARD_BASE_URL" yaml:"base-url" description:"Base URL." default:"/"`
LogoutURL string `long:"logout-url" env:"TERRABOARD_LOGOUT_URL" yaml:"logout-url" description:"Logout URL."`
}

// ProviderConfig stores genral provider parameters
Expand Down
14 changes: 8 additions & 6 deletions config/config_test.go
Expand Up @@ -75,9 +75,10 @@ func TestLoadConfig(t *testing.T) {
},
},
Web: WebConfig{
Port: 8080,
BaseURL: "/",
LogoutURL: "",
Port: 8080,
SwaggerPort: 8081,
BaseURL: "/",
LogoutURL: "",
},
}

Expand Down Expand Up @@ -142,9 +143,10 @@ func TestLoadConfigFromYaml(t *testing.T) {
},
},
Web: WebConfig{
Port: 39090,
BaseURL: "/test/",
LogoutURL: "/test-logout",
Port: 39090,
SwaggerPort: 8081,
BaseURL: "/test/",
LogoutURL: "/test-logout",
},
}

Expand Down
1 change: 1 addition & 0 deletions config/config_test.yml
Expand Up @@ -37,5 +37,6 @@ gitlab:

web:
port: 39090
swagger-port: 8081
base-url: /test/
logout-url: /test-logout
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -213,7 +213,7 @@ func main() {
httpSwagger.URL("/swagger/doc.json"),
))
swaggerRouter.Use(corsMiddleware)
go serveSwagger(8081, swaggerRouter)
go serveSwagger(int(c.Web.SwaggerPort), swaggerRouter)

// Serve static files (CSS, JS, images) from dir
spa := spaHandler{staticPath: "static", indexPath: "index.html"}
Expand Down

0 comments on commit a2b6715

Please sign in to comment.