Simplifier dataclient dans insert handler #21
1 changed files with 2 additions and 19 deletions
|
@ -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",
|
||||
|
|
Reference in a new issue