mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-24 20:57:43 +00:00
fix web
This commit is contained in:
parent
7f30f279bc
commit
ff80ef3f2a
1 changed files with 6 additions and 4 deletions
|
@ -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(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue