bottin-agenda/handlers/seed.go

36 lines
770 B
Go
Raw Normal View History

2023-06-06 02:16:54 -04:00
package handlers
import (
"fmt"
"net/http"
"git.agecem.com/agecem/bottin-agenda/data"
"git.agecem.com/agecem/bottin-agenda/responses"
"github.com/labstack/echo/v4"
)
func PostSeed(c echo.Context) error {
var response responses.PostSeedResponse
var statusCode int = http.StatusInternalServerError
client, err := data.NewDataClientFromViper()
if err != nil {
response.Message = fmt.Sprintf("Error during data.NewDataClientFromViper(): %s", err)
return c.JSON(statusCode, response)
}
_, err = client.Seed()
if err != nil {
response.Message = fmt.Sprintf("Error during client.Seed(): %s", err)
return c.JSON(statusCode, response)
}
response.Message = "Seed seems successful"
statusCode = http.StatusOK
return c.JSON(statusCode, response)
}