Files
warpbox/lib/server/server.go
Daniel Legt cf90e08f98 refactor: 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 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
2026-04-27 17:49:19 +03:00

32 lines
810 B
Go

package server
import (
"github.com/gin-contrib/gzip"
"github.com/gin-gonic/gin"
"warpbox/lib/routing"
)
func Run(addr string) error {
router := gin.Default()
router.LoadHTMLGlob("templates/*.html")
routing.Register(router, routing.Handlers{
Index: handleIndex,
ShowBox: handleShowBox,
BoxStatus: handleBoxStatus,
DownloadBox: handleDownloadBox,
DownloadFile: handleDownloadFile,
CreateBox: handleCreateBox,
ManifestFileUpload: handleManifestFileUpload,
FileStatusUpdate: handleFileStatusUpdate,
DirectBoxUpload: handleDirectBoxUpload,
LegacyUpload: handleLegacyUpload,
})
compressed := router.Group("/", gzip.Gzip(gzip.DefaultCompression))
compressed.Static("/static", "./static")
return router.Run(addr)
}