Nexus/pkg/http/api/index.go

29 lines
686 B
Go
Raw Normal View History

2024-10-19 14:36:33 +00:00
package api
import (
"github.com/gofiber/contrib/websocket"
"github.com/gofiber/fiber/v2"
)
func MapAPIs(app *fiber.App) {
// Some built-in public-accessible APIs
2024-10-19 14:36:33 +00:00
wellKnown := app.Group("/.well-known").Name("Well Known")
{
wellKnown.Get("/", func(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusOK)
})
wellKnown.Get("/check-ip", getClientIP)
wellKnown.Get("/directory/services", listExistsService)
}
// Common websocket gateway
app.Use(func(c *fiber.Ctx) error {
/*if err := exts.EnsureAuthenticated(c); err != nil {
return err
}*/
return c.Next()
}).Get("/ws", websocket.New(listenWebsocket))
2024-10-19 14:36:33 +00:00
app.All("/cgi/:service/*", forwardServiceRequest)
2024-10-19 14:36:33 +00:00
}