Skip to content

Commit

Permalink
fix(main): use port dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Mar 10, 2021
1 parent baa12e0 commit 04e7272
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ import (
"github.com/adhocore/urlsh/router"
)

func main() {
port := os.Getenv("APP_PORT")
if port == "" {
port = "1000"
func getPort() string {
if port := os.Getenv("PORT"); port != "" {
return port
}
if port := os.Getenv("APP_PORT"); port != "" {
return port
}

return "1000"
}

func main() {
port := getPort()

server := &http.Server{
Addr: ":" + port,
Handler: router.RegisterHandlers(),
Expand Down

0 comments on commit 04e7272

Please sign in to comment.