2023-11-20 14:14:00 -05:00
|
|
|
package apihandler
|
2023-07-24 14:28:55 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"sort"
|
|
|
|
|
2024-08-21 13:39:03 -04:00
|
|
|
"codeberg.org/vlbeaudoin/pave/v2"
|
2023-07-24 14:28:55 -04:00
|
|
|
"git.agecem.com/agecem/agecem-org/config"
|
|
|
|
"git.agecem.com/agecem/agecem-org/media"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
)
|
|
|
|
|
2023-08-30 13:45:07 -04:00
|
|
|
type V1Handler struct {
|
|
|
|
Config config.Config
|
|
|
|
MediaClient *media.MediaClient
|
2023-11-20 15:13:42 -05:00
|
|
|
Pave *pave.Pave
|
2023-08-30 13:45:07 -04:00
|
|
|
}
|
|
|
|
|
2023-07-24 14:28:55 -04:00
|
|
|
// API Handlers
|
|
|
|
|
2023-11-20 15:40:52 -05:00
|
|
|
// V1GET affiche les routes accessibles.
|
2023-07-24 14:28:55 -04:00
|
|
|
// Les routes sont triées selon .Path, pour les rendre plus facilement navigables.
|
2023-11-20 15:40:52 -05:00
|
|
|
func (h *V1Handler) V1GET(c echo.Context) error {
|
2023-07-24 14:28:55 -04:00
|
|
|
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)
|
|
|
|
}
|