ソースを参照

chore: use dev database port when connecting, if available

Fela Maslen 4 年 前
コミット
b624febd05
2 ファイル変更5 行追加2 行削除
  1. 4 1
      gmus-backend/pkg/config/config.go
  2. 1 1
      gmus-backend/pkg/server/handler.go

+ 4 - 1
gmus-backend/pkg/config/config.go

@@ -53,8 +53,11 @@ func getDatabaseUrl() string {
 
 	user := os.Getenv("POSTGRES_USER")
 	password := os.Getenv("POSTGRES_PASSWORD")
+	portDev, hasPortDev := os.LookupEnv("DB_PORT_GMUS_DEV")
 	port, hasPort := os.LookupEnv("POSTGRES_PORT")
-	if !hasPort {
+	if hasPortDev {
+		port = portDev
+	} else if !hasPort {
 		port = "5432"
 	}
 	portNumeric, err := strconv.Atoi(port)

+ 1 - 1
gmus-backend/pkg/server/handler.go

@@ -16,7 +16,7 @@ func routeHandler(
 ) func(w http.ResponseWriter, r *http.Request) {
 
 	return func(w http.ResponseWriter, r *http.Request) {
-		l.Verbose("[%s] %s\n", r.Method, r.URL);
+		l.Verbose("[%s] %s\n", r.Method, r.URL)
 		err := handler(l, rdb, w, r)
 
 		if err != nil {