Skip to content

Commit

Permalink
Merge branch 'parse-port-value-to-add-address' into 'main'
Browse files Browse the repository at this point in the history
chore: parse port value to add address

See merge request flattrack/flattrack!391
  • Loading branch information
BobyMCbobs committed Jul 28, 2024
2 parents 6db82e4 + 5c3250c commit 89ecbd8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import (
"encoding/hex"
"fmt"
"math/rand"
"net"
"os"
"path"
"regexp"
"strings"
"time"
)

Expand Down Expand Up @@ -143,9 +145,13 @@ func GetMigrationsPath() (output string) {
// GetAppPort ...
// return the port which the app should serve HTTP on
func GetAppPort() (output string) {
return GetEnvOrDefault("PORT",
port := GetEnvOrDefault("PORT",
GetEnvOrDefault("APP_PORT", ":8080"),
)
if _, _, err := net.SplitHostPort(port); err != nil && strings.Contains(err.Error(), "missing port in address") {
port = ":" + port
}
return port
}

// GetAppMetricsPort ...
Expand Down

0 comments on commit 89ecbd8

Please sign in to comment.