From 1ca46703756b20d2b23c8e527ef221082e057cf1 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Sat, 3 Jun 2023 19:33:56 -0400 Subject: [PATCH] Simplifier dataclient dans insert handler --- handlers/insert.go | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/handlers/insert.go b/handlers/insert.go index 0542bc5..b928942 100644 --- a/handlers/insert.go +++ b/handlers/insert.go @@ -6,19 +6,10 @@ import ( "git.agecem.com/agecem/bottin/v5/data" "git.agecem.com/agecem/bottin/v5/models" "github.com/labstack/echo/v4" - "github.com/spf13/viper" ) func PostMembres(c echo.Context) error { - connection := data.PostgresConnection{ - User: viper.GetString("db.user"), - Password: viper.GetString("db.password"), - Host: viper.GetString("db.host"), - Database: viper.GetString("db.database"), - Port: viper.GetInt("db.port"), - } - - client, err := data.NewDataClient(connection) + client, err := data.NewDataClientFromViper() if err != nil { return c.JSON(http.StatusInternalServerError, map[string]string{ "message": "Could not establish database connection", @@ -58,15 +49,7 @@ func PostMembres(c echo.Context) error { } func PostProgrammes(c echo.Context) error { - connection := data.PostgresConnection{ - User: viper.GetString("db.user"), - Password: viper.GetString("db.password"), - Host: viper.GetString("db.host"), - Database: viper.GetString("db.database"), - Port: viper.GetInt("db.port"), - } - - client, err := data.NewDataClient(connection) + client, err := data.NewDataClientFromViper() if err != nil { return c.JSON(http.StatusInternalServerError, map[string]string{ "message": "Could not establish database connection", -- 2.45.2