2024-10-19 14:36:33 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
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) {
|
2024-10-20 07:22:19 +00:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2024-10-20 07:22:19 +00:00
|
|
|
// Common websocket gateway
|
|
|
|
app.Use(func(c *fiber.Ctx) error {
|
|
|
|
/*if err := exts.EnsureAuthenticated(c); err != nil {
|
|
|
|
return err
|
|
|
|
}*/
|
|
|
|
return c.Next()
|
2024-10-20 11:04:41 +00:00
|
|
|
}).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
|
|
|
}
|