package admin import ( "context" "gitea.tbdevent.eu/TBD/reforger_crawler_main/auth" "github.com/gin-gonic/gin" ) // Register mounts the admin JSON API under /admin/api and the legacy // header-authenticated /admin/addWhitelistedHash endpoint. func Register(r *gin.Engine) { r.POST("/admin/addWhitelistedHash", auth.RequireAdminHeader, legacyAddWhitelistedHash) api := r.Group("/admin/api") api.POST("/auth/login", login) api.POST("/auth/logout", logout) p := api.Group("", auth.RequireAdmin) p.GET("/auth/me", me) p.GET("/overview", overview) p.GET("/overview/duplicates", duplicateHashes) p.POST("/overview/duplicates/refresh", refreshDuplicates) p.GET("/queue", queue) p.POST("/queue/reset-stuck", resetStuck) p.GET("/addons", listAddons) p.GET("/addons/:id", addonDetail) p.GET("/addons/:id/files", addonFiles) p.POST("/addons/:id/:action", addonAction) p.DELETE("/addons/:id", deleteAddon) p.DELETE("/addons/:id/purge", purgeAddon) p.POST("/bulk/addons", bulkAddons) p.GET("/whitelist", listWhitelist) p.POST("/whitelist", addWhitelist) p.DELETE("/whitelist/:id", deleteWhitelist) p.GET("/hashes/:hash", hashUsage) p.GET("/metrics/catalog", metricsCatalog) p.GET("/metrics/query", metricsQuery) p.GET("/traffic", traffic) p.GET("/top", topItems) p.GET("/services", listServices) p.GET("/services/events", listEvents) p.DELETE("/services/:id", deleteService) p.GET("/system", system) p.POST("/system/maintenance", maintenance) } // StartBackground runs the periodic heavy statistics job. func StartBackground(ctx context.Context) { go heavyStatsLoop(ctx) }