agecem-org/apihandler/apihandler.go

28 lines
659 B
Go
Raw Normal View History

package apihandler
import (
"net/http"
"sort"
"codeberg.org/vlbeaudoin/pave/v2"
"git.agecem.com/agecem/agecem-org/config"
"git.agecem.com/agecem/agecem-org/media"
"github.com/labstack/echo/v4"
)
type V1Handler struct {
Config config.Config
MediaClient *media.MediaClient
Pave *pave.Pave
}
// API Handlers
// V1GET affiche les routes accessibles.
// Les routes sont triées selon .Path, pour les rendre plus facilement navigables.
func (h *V1Handler) V1GET(c echo.Context) error {
routes := c.Echo().Routes()
sort.Slice(routes, func(i, j int) bool { return routes[i].Path < routes[j].Path })
return c.JSON(http.StatusOK, routes)
}