Skip to content

Commit

Permalink
Merge pull request #8 from m-mattia-m/develop
Browse files Browse the repository at this point in the history
make port in swagger configurable (and document it)
  • Loading branch information
m-mattia-m authored Nov 23, 2023
2 parents 9bc01b2 + ad24665 commit 5204c6a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 20 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ data:
verifyDns: 8.8.8.8:53 # this is optional -> if not set then the google standard is used ("8.8.8.8:53")
activity:
enable:
subject: true
message: true
subject: true # this is optional
message: true # this is optional
swagger:
port: false # this is optional
```

```yaml {filename="k8s-manifest-secret.yaml"}
Expand Down Expand Up @@ -712,8 +714,11 @@ domain:
verifyDns: 8.8.8.8:53 # this is optional -> if not set then the google standard is used ("8.8.8.8:53")
activity:
enable:
subject: true # required
message: true # required
subject: true # optional
message: true # optional
swagger:
port: false # optional
```

## Environment
Expand Down
20 changes: 17 additions & 3 deletions docs/content/docs/self-hosted/domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ domain:
verifyDns: 8.8.8.8:53 # this is optional -> if not set then the google standard is used ("8.8.8.8:53")
activity:
enable:
subject: true
message: true
subject: true # this is optional
message: true # this is optional
swagger:
port: false # this is optional
```
## DNS
Expand All @@ -38,4 +40,16 @@ domain:
enable:
subject: true # optional -> default: false
message: true # optional -> default: false
```
```

## Swagger

It could be, that you don't need the port in the swagger-configuration. For this you can disable it in the config. Note,
the port is needed to start the API.

```yaml {filename="./configs/config.yaml"}
domain:
swagger:
port: false # this is optional
```

2 changes: 2 additions & 0 deletions docs/content/docs/self-hosted/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ domain:
enable:
subject: true # optional
message: true # optional
swagger:
port: false # this is optional
```
## Environment
Expand Down
7 changes: 6 additions & 1 deletion internal/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ func Router(svc service.Service) *gin.Engine {
gin.SetMode(gin.ReleaseMode)
}

swaggerPort := ""
if viper.GetBool("domain.swagger.port") {
swaggerPort = fmt.Sprintf(":%s", viper.GetString("server.port"))
}

docs.SwaggerInfo.Schemes = []string{viper.GetString("server.scheme")}
docs.SwaggerInfo.Host = fmt.Sprintf("%s:%s", viper.GetString("server.domain"), viper.GetString("server.port"))
docs.SwaggerInfo.Host = fmt.Sprintf("%s%s", viper.GetString("server.domain"), swaggerPort)
docs.SwaggerInfo.BasePath = fmt.Sprintf("/%s", viper.GetString("server.version"))

r := gin.Default()
Expand Down
27 changes: 15 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ func checkIfRequiredConfigurationAttributesSet() {
if viper.GetString("server.version") == "" {
log.Fatal("failed to get required config attribute: 'server.version'")
}
if viper.GetString("logging.enable.console") == "" {
log.Fatal("failed to get required config attribute: 'logging.enable.console'")
}
if viper.GetString("logging.enable.sentry") == "" {
log.Fatal("failed to get required config attribute: 'logging.enable.sentry'")
}
//if viper.GetString("logging.enable.console") == "" {
// log.Fatal("failed to get required config attribute: 'logging.enable.console'")
//}
//if viper.GetString("logging.enable.sentry") == "" {
// log.Fatal("failed to get required config attribute: 'logging.enable.sentry'")
//}
if viper.GetString("authentication.oidc.issuer") == "" {
log.Fatal("failed to get required config attribute: 'authentication.oidc.issuer'")
}
Expand All @@ -166,10 +166,13 @@ func checkIfRequiredConfigurationAttributesSet() {
if viper.GetString("frontend.url") == "" {
log.Fatal("failed to get required config attribute: 'frontend.url'")
}
if viper.GetString("domain.activity.enable.subject") == "" {
log.Fatal("failed to get required config attribute: 'domain.activity.enable.subject'")
}
if viper.GetString("domain.activity.enable.message") == "" {
log.Fatal("failed to get required config attribute: 'failed to get required config attribute'")
}
//if viper.GetString("domain.activity.enable.subject") == "" {
// log.Fatal("failed to get required config attribute: 'domain.activity.enable.subject'")
//}
//if viper.GetString("domain.activity.enable.message") == "" {
// log.Fatal("failed to get required config attribute: 'domain.activity.enable.message'")
//}
//if viper.GetString("domain.swagger.port") == "" {
// log.Fatal("failed to get required config attribute: 'failed to get required config attribute'")
//}
}

0 comments on commit 5204c6a

Please sign in to comment.