Nexus/pkg/internal/http/api/index.go

27 lines
724 B
Go
Raw Normal View History

2024-10-19 14:36:33 +00:00
package api
import (
"git.solsynth.dev/hypernet/nexus/pkg/internal/auth"
2024-10-20 16:05:40 +00:00
"git.solsynth.dev/hypernet/nexus/pkg/internal/http/ws"
2024-10-19 14:36:33 +00:00
"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(auth.ValidatorMiddleware).Get("/ws", websocket.New(ws.Listen))
2024-10-19 14:36:33 +00:00
2024-10-20 16:05:40 +00:00
app.All("/inv/:command", invokeCommand)
app.All("/cgi/:service/*", forwardService)
2024-10-19 14:36:33 +00:00
}