Bump root version to v4
Remove all files from v3 Move all files from v4/ to project root
This commit is contained in:
parent
3c0d45fa04
commit
9a0bf87e7b
40 changed files with 423 additions and 2130 deletions
42
handlers/seed.go
Normal file
42
handlers/seed.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.agecem.com/agecem/bottin/v4/data"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func PostSeed(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)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, map[string]string{
|
||||
"message": "Could not establish database connection",
|
||||
"error": err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
rows, err := client.Seed()
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, map[string]string{
|
||||
"message": "Seed failed",
|
||||
"error": err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, map[string]interface{}{
|
||||
"message": "Seed successful",
|
||||
"data": map[string]interface{}{
|
||||
"rows": rows,
|
||||
},
|
||||
})
|
||||
}
|
Reference in a new issue