From 9f1d4e01d442e2c0ac393465252b793097264c62 Mon Sep 17 00:00:00 2001 From: takumi Date: Sun, 31 Dec 2023 11:20:45 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20DB=E6=8E=A5=E7=B6=9A=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/init.go | 4 ++-- database/init_gorm.go | 6 ++++-- main.go | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/database/init.go b/database/init.go index 30425bd..a57d2b3 100644 --- a/database/init.go +++ b/database/init.go @@ -18,9 +18,9 @@ func DBConnect() (*sql.DB, error) { dbPassword := os.Getenv("DB_PASSWORD") dbName := os.Getenv("DB_NAME") dbPort := os.Getenv("DB_PORT") - dbHost := "127.0.0.1" + dbHost := os.Getenv("DB_HOST") dbConn := fmt.Sprintf( - "%s:%s@tcp(%s:%s)/%s?parseTime=true", + "%s:%s@tcp(%s:%s)/%s?parseTime=true&tls=true&interpolateParams=true", dbUser, dbPassword, dbHost, diff --git a/database/init_gorm.go b/database/init_gorm.go index ea01836..2077485 100644 --- a/database/init_gorm.go +++ b/database/init_gorm.go @@ -19,14 +19,16 @@ func DBConnectGorm() (db *gorm.DB, err error) { dbPassword := os.Getenv("DB_PASSWORD") dbName := os.Getenv("DB_NAME") dbPort := os.Getenv("DB_PORT") - dbHost := "127.0.0.1" + dbHost := os.Getenv("DB_HOST") + dbTls := os.Getenv("DB_TLS") dbConn := fmt.Sprintf( - "%s:%s@tcp(%s:%s)/%s?parseTime=true", + "%s:%s@tcp(%s:%s)/%s?parseTime=true&tls=%s&interpolateParams=true", dbUser, dbPassword, dbHost, dbPort, dbName, + dbTls, ) db, err = gorm.Open(mysql.Open(dbConn), &gorm.Config{}) diff --git a/main.go b/main.go index 702c1c7..099664e 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,7 @@ type TestResponse struct { func (s Server) GetApiEvent(ctx echo.Context, params openapi.GetApiEventParams) error { return ctx.JSON(http.StatusOK, TestResponse{ - Message: "search events", + Message: "get events", }) }