- Move API request/response structs into new lib/models package - Centralize Gin route registration in lib/routing to simplify wiring - Add lib/server config helper to allow WARPBOX_BOX_POLL_INTERVAL_MS override - Improves modularity and makes polling behavior configurable per environmentrefactor: extract models/routes and env-based server config - Move API request/response structs into new lib/models package - Centralize Gin route registration in lib/routing to simplify wiring - Add lib/server config helper to allow WARPBOX_BOX_POLL_INTERVAL_MS override - Improves modularity and makes polling behavior configurable per environment
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
package routing
|
|
|
|
import "github.com/gin-gonic/gin"
|
|
|
|
type Handlers struct {
|
|
Index gin.HandlerFunc
|
|
ShowBox gin.HandlerFunc
|
|
BoxStatus gin.HandlerFunc
|
|
DownloadBox gin.HandlerFunc
|
|
DownloadFile gin.HandlerFunc
|
|
CreateBox gin.HandlerFunc
|
|
ManifestFileUpload gin.HandlerFunc
|
|
FileStatusUpdate gin.HandlerFunc
|
|
DirectBoxUpload gin.HandlerFunc
|
|
LegacyUpload gin.HandlerFunc
|
|
}
|
|
|
|
func Register(router *gin.Engine, handlers Handlers) {
|
|
router.GET("/", handlers.Index)
|
|
|
|
router.GET("/box/:id", handlers.ShowBox)
|
|
router.GET("/box/:id/status", handlers.BoxStatus)
|
|
router.GET("/box/:id/download", handlers.DownloadBox)
|
|
router.GET("/box/:id/files/:filename", handlers.DownloadFile)
|
|
|
|
router.POST("/box", handlers.CreateBox)
|
|
router.POST("/box/:id/files/:file_id/upload", handlers.ManifestFileUpload)
|
|
router.POST("/box/:id/files/:file_id/status", handlers.FileStatusUpdate)
|
|
|
|
// Legacy upload routes are kept for compatibility with older clients.
|
|
router.POST("/box/:id/upload", handlers.DirectBoxUpload)
|
|
router.POST("/upload", handlers.LegacyUpload)
|
|
}
|