Simplifier dataclient dans insert handler
This commit is contained in:
parent
58de9758a7
commit
1ca4670375
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/data"
|
||||||
"git.agecem.com/agecem/bottin/v5/models"
|
"git.agecem.com/agecem/bottin/v5/models"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/spf13/viper"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func PostMembres(c echo.Context) error {
|
func PostMembres(c echo.Context) error {
|
||||||
connection := data.PostgresConnection{
|
client, err := data.NewDataClientFromViper()
|
||||||
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)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, map[string]string{
|
return c.JSON(http.StatusInternalServerError, map[string]string{
|
||||||
"message": "Could not establish database connection",
|
"message": "Could not establish database connection",
|
||||||
|
@ -58,15 +49,7 @@ func PostMembres(c echo.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func PostProgrammes(c echo.Context) error {
|
func PostProgrammes(c echo.Context) error {
|
||||||
connection := data.PostgresConnection{
|
client, err := data.NewDataClientFromViper()
|
||||||
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)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, map[string]string{
|
return c.JSON(http.StatusInternalServerError, map[string]string{
|
||||||
"message": "Could not establish database connection",
|
"message": "Could not establish database connection",
|
||||||
|
|
Loading…
Reference in a new issue