package server import ( "time" "github.com/gin-contrib/gzip" "github.com/gin-gonic/gin" "warpbox/lib/boxstore" "warpbox/lib/helpers" "warpbox/lib/routing" ) func Run(addr string) error { router := gin.Default() router.LoadHTMLGlob("templates/*.html") routing.Register(router, routing.Handlers{ Index: handleIndex, ShowBox: handleShowBox, BoxLogin: handleBoxLogin, BoxLoginPost: handleBoxLoginPost, BoxStatus: handleBoxStatus, DownloadBox: handleDownloadBox, DownloadFile: handleDownloadFile, DownloadThumbnail: handleDownloadThumbnail, CreateBox: handleCreateBox, ManifestFileUpload: handleManifestFileUpload, FileStatusUpdate: handleFileStatusUpdate, DirectBoxUpload: handleDirectBoxUpload, LegacyUpload: handleLegacyUpload, }) compressed := router.Group("/", gzip.Gzip(gzip.DefaultCompression)) compressed.Static("/static", "./static") batchSize := helpers.EnvInt("WARPBOX_THUMBNAIL_BATCH_SIZE", 10, 1) intervalSeconds := helpers.EnvInt("WARPBOX_THUMBNAIL_INTERVAL_SECONDS", 30, 1) boxstore.StartThumbnailWorker(batchSize, time.Duration(intervalSeconds)*time.Second) return router.Run(addr) }