fix: port should actually be used, use port as int in api request
This commit is contained in:
parent
32e186d502
commit
cad2855220
2 changed files with 13 additions and 7 deletions
|
@ -12,8 +12,9 @@ REDIRECT_URI=http://localhost:8081/api/auth/callback
|
||||||
CLIENT_ID=
|
CLIENT_ID=
|
||||||
CLIENT_SECRET=
|
CLIENT_SECRET=
|
||||||
|
|
||||||
# Listening port
|
# Listen address (if the IP address is empty, it will default to 127.0.0.1)
|
||||||
PORT=
|
# e.g. 127.0.0.1:8081 or :8081
|
||||||
|
LISTEN_ADDRESS=:8081
|
||||||
|
|
||||||
# S3
|
# S3
|
||||||
S3_ENDPOINT=
|
S3_ENDPOINT=
|
||||||
|
|
15
main.go
15
main.go
|
@ -27,6 +27,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
|
@ -61,7 +62,7 @@ func main() {
|
||||||
databaseType := getEnv("DATABASE_TYPE", "sqlite")
|
databaseType := getEnv("DATABASE_TYPE", "sqlite")
|
||||||
sqliteFile := getEnv("SQLITE_FILE", "stereo.db")
|
sqliteFile := getEnv("SQLITE_FILE", "stereo.db")
|
||||||
boxyApiUrl := getEnv("BOXY_URL", "")
|
boxyApiUrl := getEnv("BOXY_URL", "")
|
||||||
port := getEnv("PORT", "8081")
|
listenAddr := getEnv("LISTEN_ADDRESS", ":8081")
|
||||||
|
|
||||||
imagePath := getEnv("IMAGE_PATH", os.TempDir())
|
imagePath := getEnv("IMAGE_PATH", os.TempDir())
|
||||||
|
|
||||||
|
@ -134,6 +135,10 @@ func main() {
|
||||||
boxyClientSecret := requireEnv("BOXY_CLIENT_SECRET")
|
boxyClientSecret := requireEnv("BOXY_CLIENT_SECRET")
|
||||||
boxyClientAddress := getEnv("BOXY_CLIENT_ADDRESS", "")
|
boxyClientAddress := getEnv("BOXY_CLIENT_ADDRESS", "")
|
||||||
|
|
||||||
|
port, err := strconv.Atoi(strings.Split(listenAddr, ":")[1])
|
||||||
|
|
||||||
|
fmt.Printf("Using port %d\n", port)
|
||||||
|
|
||||||
rawBody := map[string]any{
|
rawBody := map[string]any{
|
||||||
"port": port,
|
"port": port,
|
||||||
"hostname": c.Domain,
|
"hostname": c.Domain,
|
||||||
|
@ -152,9 +157,9 @@ func main() {
|
||||||
|
|
||||||
req.SetBasicAuth(boxyClientName, boxyClientSecret)
|
req.SetBasicAuth(boxyClientName, boxyClientSecret)
|
||||||
|
|
||||||
http.DefaultClient.Do(req)
|
resp, _ := http.DefaultClient.Do(req)
|
||||||
|
|
||||||
if req.Response.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
log.Fatal("Could not register with Boxy.\nStatus Code: " + strconv.Itoa(req.Response.StatusCode))
|
log.Fatal("Could not register with Boxy.\nStatus Code: " + strconv.Itoa(req.Response.StatusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -163,6 +168,6 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
api.Register(&c)
|
api.Register(&c)
|
||||||
fmt.Printf("Running on port %s\n", port)
|
fmt.Printf("Listening on %s\n", listenAddr)
|
||||||
c.Router.Run()
|
c.Router.Run(listenAddr)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue