From 316323587d47164e663941685b7cca29baff4a4c Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Sat, 18 Jun 2022 13:51:37 +0200 Subject: [PATCH] [fix] Restored DB connection --- cmd/server/main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index ef78d9e..137da91 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "git.pbiernat.dev/golang/rest-api-prototype/internal/app/database" "log" "net" "os" @@ -16,7 +17,7 @@ import ( const ( defHttpIp = "127.0.0.1" defHttpPort = "8080" - defDbUrl = "postgres://postgres:postgres@127.0.0.1:5432/Api" // FIXME use default container conf in future + defDbUrl = "postgres://postgres:postgres@127.0.0.1:5432/Api" // FIXME: use env ) func main() { @@ -25,15 +26,14 @@ func main() { } httpAddr := net.JoinHostPort(config.GetEnv("SERVER_IP", defHttpIp), config.GetEnv("SERVER_PORT", defHttpPort)) - // dbConnStr := config.GetEnv("DATABASE_URL", defDbUrl) + dbConnStr := config.GetEnv("DATABASE_URL", defDbUrl) - // dbc, err := database.Connect(dbConnStr) - // if err != nil { - // log.Panicf("Unable to connect to database: %v\n", err) - // } + dbc, err := database.Connect(dbConnStr) + if err != nil { + log.Panicf("Unable to connect to database: %v\n", err) + } - // env := &handler.Env{httpAddr, dbc} - env := &handler.Env{httpAddr, nil} + env := &handler.Env{httpAddr, dbc} srv := app.NewServer(env) go srv.Start()