package handlers import ( "net/http" "github.com/labstack/echo/v4" "github.com/spf13/viper" bottindata "git.agecem.com/agecem/bottin/v5/data" ) func GetMembre(c echo.Context) error { bottinApiKey := viper.GetString("bottin.api.key") bottinApiHost := viper.GetString("bottin.api.host") bottinApiProtocol := viper.GetString("bottin.api.protocol") bottinApiPort := viper.GetInt("bottin.api.port") // Using bottin's API client bottinConnection := bottindata.NewApiClient( bottinApiKey, bottinApiHost, bottinApiProtocol, bottinApiPort, ) membreID := c.Param("membre_id") membre, err := bottinConnection.GetMembre(membreID) if err != nil { if err.Error() == "No membre by that id was found" { return c.JSON(http.StatusNotFound, map[string]string{ "message": "Not Found", }) } return c.JSON(http.StatusInternalServerError, map[string]string{ "message": "Unknown error during GetMembre", "error": err.Error(), }) } return c.JSON(http.StatusOK, map[string]interface{}{ "message": "Read successful", "data": map[string]interface{}{ "membre": &membre, }, }) }