This commit is contained in:
Andre Medeiros 2021-07-05 20:23:50 -04:00
parent 7f30f279bc
commit ff80ef3f2a

View file

@ -2,7 +2,6 @@ package main
import ( import (
"database/sql" "database/sql"
"flag"
"fmt" "fmt"
"log" "log"
"net/http" "net/http"
@ -35,8 +34,6 @@ func main() {
} }
var cfg config var cfg config
flag.IntVar(&cfg.port, "port", 4000, "API server port")
flag.Parse()
db, err := sql.Open("postgres", os.Getenv("DATABASE_URL")) db, err := sql.Open("postgres", os.Getenv("DATABASE_URL"))
if err != nil { if err != nil {
@ -54,8 +51,13 @@ func main() {
rc, rc,
} }
port, ok := os.LookupEnv("PORT")
if !ok {
port = "4000"
}
srv := &http.Server{ srv := &http.Server{
Addr: fmt.Sprintf(":%d", cfg.port), Addr: fmt.Sprintf(":%s", port),
Handler: app.routes(), Handler: app.routes(),
} }