agecem-org/apihandler/spec.go

37 lines
934 B
Go
Raw Permalink Normal View History

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) V1SpecGET(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\n", 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)
}