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

@@ -123,6 +123,7 @@ There are a bunch of environmental variables that can be set inside the docker c
* `SIGNAL_CLI_GID`: Specifies the gid of the `signal-api` group inside the docker container. Defaults to `1000`
* `SWAGGER_IP`: The IP that's used in the Swagger UI for the interactive examples. Defaults to the container ip.
## Clients & Libraries

View File

@@ -29,5 +29,7 @@ service supervisor start
supervisorctl start all
fi
export HOST_IP=$(hostname -i)
# Start API as signal-api user
exec setpriv --reuid=${SIGNAL_CLI_UID} --regid=${SIGNAL_CLI_GID} --init-groups --inh-caps=$caps signal-cli-rest-api -signal-cli-config=${SIGNAL_CLI_CONFIG_DIR}

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))