package main import ( "git.sp4ke.com/sp4ke/bit4sat/storage" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" ) var ( UploadCtrl = storage.UploadCtrl{} ) type API struct { router *gin.Engine } func (api *API) Run() { uploadRoute := api.router.Group("/api/upload") { uploadRoute.POST("", UploadCtrl.New) uploadRoute.PUT(":id", UploadCtrl.Upload) } websocket := api.router.Group("/ws") { websocket.GET("/", serveWebsocket) websocket.GET("/WS", serveWebsocket) websocket.GET("/WSS", serveWebsocket) } api.router.Run(":8880") } func NewAPI() *API { router := gin.Default() router.Use(cors.Default()) // //router.Use(secure.New(secure.Config{ //ContentSecurityPolicy: "default-src 'self'; script-src *; worker-src *", ////IsDevelopment: true, //})) return &API{ router: router, } }