agecem-org/apihandler/spec.go
Victor Lacasse-Beaudoin ffd8109d27 change!: renommer HandleV1Spec à V1SpecGET
BREAKING: renommer `HandleV1Spec` à `V1SpecGET`
2023-11-20 15:28:37 -05:00

36 lines
932 B
Go

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", 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)
}