Cancels a pending or running scan job. Responses: 200 with the job id and status on acceptance, 404 for unknown jobs, 409 for jobs already in a terminal state (completed/failed/cancelled). Additive route in the existing admin scanner group; no contract pins affected.
29 lines
999 B
Go
29 lines
999 B
Go
package router
|
|
|
|
import (
|
|
"bookhoard/internal/handlers"
|
|
|
|
"github.com/labstack/echo/v5"
|
|
)
|
|
|
|
// registerScannerRoutes registers all scanner-related endpoints
|
|
func registerScannerRoutes(protected, admin *echo.Group, h *handlers.Handler) {
|
|
// Any authenticated user: the sitewide sidebar indicator needs to
|
|
// know a scan is running after a page refresh (websocket events
|
|
// only reach pages that were already open).
|
|
protected.GET("/scanner/active-summary", h.GetScanSummary)
|
|
|
|
// Scanner routes (admin only)
|
|
admin.POST("/scanner/scan", h.ScanLibrary)
|
|
admin.POST("/scanner/start", h.StartScanner)
|
|
admin.POST("/scanner/stop", h.StopScanner)
|
|
admin.POST("/scanner/cancel/:jobId", h.CancelScan)
|
|
admin.GET("/scanner/status/:jobId", h.GetScanStatus)
|
|
admin.GET("/scanner/active", h.GetActiveScans)
|
|
|
|
// Watch mode routes (admin only)
|
|
admin.POST("/scanner/watch/start", h.StartWatchMode)
|
|
admin.POST("/scanner/watch/stop", h.StopWatchMode)
|
|
admin.GET("/scanner/watch/status", h.GetWatchModeStatus)
|
|
}
|