made swagger ip configurable

* the swagger ip used in the interactive examples is now configurable.

see #225
This commit is contained in:
Bernhard B
2022-03-04 21:18:36 +01:00
parent 30341f27c7
commit f411b558a8
3 changed files with 12 additions and 5 deletions

View File

@@ -69,6 +69,15 @@ func main() {
router.Use(gin.Recovery())
port := utils.GetEnv("PORT", "8080")
if _, err := strconv.Atoi(port); err != nil {
log.Fatal("Invalid PORT ", port, " set. PORT needs to be a number")
}
defaultSwaggerIp := utils.GetEnv("HOST_IP", "127.0.0.1")
swaggerIp := utils.GetEnv("SWAGGER_IP", defaultSwaggerIp)
docs.SwaggerInfo.Host = swaggerIp + ":" + port
log.Info("Started Signal Messenger REST API")
supportsSignalCliNative := "0"
@@ -229,11 +238,6 @@ func main() {
}
}
port := utils.GetEnv("PORT", "8080")
if _, err := strconv.Atoi(port); err != nil {
log.Fatal("Invalid PORT ", port, " set. PORT needs to be a number")
}
swaggerUrl := ginSwagger.URL("http://127.0.0.1:" + string(port) + "/swagger/doc.json")
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, swaggerUrl))