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

32 lines
854 B
Go
Raw Normal View History

2024-10-19 14:36:33 +00:00
package api
import (
2024-11-13 14:26:54 +00:00
pkg "git.solsynth.dev/hypernet/nexus/pkg/internal"
"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 {
2024-11-13 14:26:54 +00:00
return c.JSON(fiber.Map{
"api_level": pkg.ApiLevel,
"version": pkg.AppVersion,
"status": true,
})
2024-10-19 14:36:33 +00:00
})
wellKnown.Get("/check-ip", getClientIP)
wellKnown.Get("/directory/services", listExistsService)
}
// Common websocket gateway
app.Get("/ws", auth.ValidatorMiddleware, 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
}