diff --git a/api/s5.go b/api/s5.go index 5cbfdfd..6373b8e 100644 --- a/api/s5.go +++ b/api/s5.go @@ -1,6 +1,7 @@ package api import ( + "git.lumeweb.com/LumeWeb/portal/api/middleware" "git.lumeweb.com/LumeWeb/portal/api/s5" "git.lumeweb.com/LumeWeb/portal/interfaces" "git.lumeweb.com/LumeWeb/portal/protocols" @@ -27,35 +28,38 @@ func (s S5API) Initialize(portal interfaces.Portal, protocol interfaces.Protocol } func getRoutes(h *s5.HttpHandler, portal interfaces.Portal) map[string]jape.Handler { + + tusHandler := middleware.BuildS5TusApi(portal) + return map[string]jape.Handler{ // Account API "GET /s5/account/register": h.AccountRegisterChallenge, "POST /s5/account/register": h.AccountRegister, "GET /s5/account/login": h.AccountLoginChallenge, "POST /s5/account/login": h.AccountLogin, - "GET /s5/account": s5.AuthMiddleware(h.AccountInfo, portal), - "GET /s5/account/stats": s5.AuthMiddleware(h.AccountStats, portal), - "GET /s5/account/pins.bin": s5.AuthMiddleware(h.AccountPins, portal), + "GET /s5/account": middleware.AuthMiddleware(h.AccountInfo, portal), + "GET /s5/account/stats": middleware.AuthMiddleware(h.AccountStats, portal), + "GET /s5/account/pins.bin": middleware.AuthMiddleware(h.AccountPins, portal), // Upload API - "POST /s5/upload": s5.AuthMiddleware(h.SmallFileUpload, portal), - "POST /s5/upload/directory": s5.AuthMiddleware(h.DirectoryUpload, portal), + "POST /s5/upload": middleware.AuthMiddleware(h.SmallFileUpload, portal), + "POST /s5/upload/directory": middleware.AuthMiddleware(h.DirectoryUpload, portal), // Download API - "GET /s5/blob/:cid": s5.AuthMiddleware(h.DownloadBlob, portal), + "GET /s5/blob/:cid": middleware.AuthMiddleware(h.DownloadBlob, portal), "GET /s5/metadata/:cid": h.DownloadMetadata, // Pins API - "POST /s5/pin/:cid": s5.AuthMiddleware(h.AccountPin, portal), - "DELETE /s5/delete/:cid": s5.AuthMiddleware(h.AccountPinDelete, portal), + "POST /s5/pin/:cid": middleware.AuthMiddleware(h.AccountPin, portal), + "DELETE /s5/delete/:cid": middleware.AuthMiddleware(h.AccountPinDelete, portal), // Debug API - "GET /s5/debug/download_urls/:cid": s5.AuthMiddleware(h.DebugDownloadUrls, portal), - "GET /s5/debug/storage_locations/:hash": s5.AuthMiddleware(h.DebugStorageLocations, portal), + "GET /s5/debug/download_urls/:cid": middleware.AuthMiddleware(h.DebugDownloadUrls, portal), + "GET /s5/debug/storage_locations/:hash": middleware.AuthMiddleware(h.DebugStorageLocations, portal), - //Registry API - "GET /s5/registry": s5.AuthMiddleware(h.RegistryQuery, portal), - "POST /s5/registry": s5.AuthMiddleware(h.RegistrySet, portal), - "GET /s5/registry/subscription": s5.AuthMiddleware(h.RegistrySubscription, portal), + // Registry API + "GET /s5/registry": middleware.AuthMiddleware(h.RegistryQuery, portal), + "POST /s5/registry": middleware.AuthMiddleware(h.RegistrySet, portal), + "GET /s5/registry/subscription": middleware.AuthMiddleware(h.RegistrySubscription, portal), } }