mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-22 17:14:26 +01:00
made swagger ip configurable
* the swagger ip used in the interactive examples is now configurable. see #225
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
14
src/main.go
14
src/main.go
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user