Dealer/pkg/internal/server/api/index.go
LittleSheep 466b240e95
Some checks failed
release-nightly / build-docker (push) Has been cancelled
🎉 Initial Commit
2024-07-14 20:25:30 +08:00

29 lines
614 B
Go

package api
import (
"git.solsynth.dev/hydrogen/dealer/pkg/internal/server/exts"
"github.com/gofiber/contrib/websocket"
"github.com/gofiber/fiber/v2"
)
func MapAPIs(app *fiber.App) {
wellKnown := app.Group("/.well-known").Name("Well Known")
{
wellKnown.Get("/directory/services", listExistsService)
}
api := app.Group("/api").Name("API")
{
api.Use(func(c *fiber.Ctx) error {
if err := exts.EnsureAuthenticated(c); err != nil {
return err
}
return c.Next()
}).Get("/ws", websocket.New(listenWebsocket))
api.All("/*", func(c *fiber.Ctx) error {
return fiber.ErrNotFound
})
}
}