package handlers import ( "net/http" "github.com/labstack/echo/v4" ) func (h *Handler) PutMembrePreferedName(c echo.Context) error { membreID := c.Param("membre_id") var newName string err := c.Bind(&newName) if err != nil { return c.JSON(http.StatusBadRequest, map[string]string{ "message": "Could not bind newName", "error": err.Error(), }) } rows, err := h.DataClient.UpdateMembreName(membreID, newName) if err != nil { return c.JSON(http.StatusInternalServerError, map[string]string{ "message": "Could not update membre name", "error": err.Error(), }) } if rows == 0 { return c.JSON(http.StatusBadRequest, map[string]string{ "message": "No update was done, probably no membre by that id", }) } return c.JSON(http.StatusOK, map[string]interface{}{ "message": "Update successful", "data": map[string]interface{}{ "rows": rows, }, }) }