WatchTower admin API

This commit is contained in:
LittleSheep 2025-01-30 22:24:58 +08:00
parent bda9ab6c3d
commit 7cf9b80fe6
2 changed files with 21 additions and 0 deletions

View File

@ -41,6 +41,12 @@ func MapAPIs(app *fiber.App) {
}) })
} }
// WatchTower administration APIs
wt := app.Group("/watchtower").Name("WatchTower").Use(auth.ValidatorMiddleware)
{
wt.Post("/maintenance/database", wtRunDbMaintenance)
}
// Common websocket gateway // Common websocket gateway
app.Get("/ws", auth.ValidatorMiddleware, websocket.New(ws.Listen)) app.Get("/ws", auth.ValidatorMiddleware, websocket.New(ws.Listen))

View File

@ -0,0 +1,15 @@
package api
import (
"git.solsynth.dev/hypernet/nexus/pkg/internal/watchtower"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
)
func wtRunDbMaintenance(c *fiber.Ctx) error {
if err := sec.EnsureGrantedPerm(c, "AdminOperateWatchTower", true); err != nil {
return err
}
go watchtower.RunDbMaintenance()
return c.SendStatus(fiber.StatusOK)
}