package apihandler import ( "fmt" "net/http" "git.agecem.com/agecem/agecem-org/apirequest" "git.agecem.com/agecem/agecem-org/apiresponse" "git.agecem.com/agecem/agecem-org/version" "github.com/labstack/echo/v4" ) const DescriptionV1SpecGET string = "Afficher le API spec en format pave" func (h *V1Handler) HandleV1Spec(c echo.Context) error { var request apirequest.V1SpecGET var response apiresponse.V1SpecGET if !request.Complete() { response.Message = "Incomplete V1SpecGET request received" response.StatusCode = http.StatusBadRequest return c.JSON(response.StatusCode, response) } response.Data.Spec = fmt.Sprintf("# pave spec for agecem-org %s", version.Version()) for _, route := range h.Pave.SortedRouteStrings() { response.Data.Spec = fmt.Sprintf("%s%s", response.Data.Spec, route) } response.Message = "ok" response.StatusCode = http.StatusOK return c.JSON(response.StatusCode, response) }