refactor: fix import cycles

This commit is contained in:
Derrick Hammer 2024-01-19 17:11:16 -05:00
parent 72219eb59c
commit 1f7c05434a
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 15 additions and 9 deletions

View File

@ -20,10 +20,3 @@ func registerProtocolSubdomain(portal interfaces.Portal, mux *httprouter.Router,
(*router)[name+"."+domain] = mux
}
func ApplyMiddlewares(handler jape.Handler, middlewares ...MiddlewareFunc) jape.Handler {
// Apply each middleware in reverse order
for i := len(middlewares) - 1; i >= 0; i-- {
handler = middlewares[i](handler)
}
return handler
}

View File

@ -3,7 +3,6 @@ package middleware
import (
"context"
"fmt"
"git.lumeweb.com/LumeWeb/portal/api"
"git.lumeweb.com/LumeWeb/portal/interfaces"
"github.com/golang-jwt/jwt/v5"
"go.sia.tech/jape"
@ -125,7 +124,7 @@ func BuildS5TusApi(portal interfaces.Portal) jape.Handler {
})
// Apply the middlewares to the tusJapeHandler
tusHandler := api.ApplyMiddlewares(tusJapeHandler, adaptedTusMiddleware, authMiddlewareFunc, protocolMiddleware)
tusHandler := ApplyMiddlewares(tusJapeHandler, adaptedTusMiddleware, authMiddlewareFunc, protocolMiddleware)
return tusHandler
}

14
api/middleware/util.go Normal file
View File

@ -0,0 +1,14 @@
package middleware
import (
"git.lumeweb.com/LumeWeb/portal/api"
"go.sia.tech/jape"
)
func ApplyMiddlewares(handler jape.Handler, middlewares ...api.MiddlewareFunc) jape.Handler {
// Apply each middleware in reverse order
for i := len(middlewares) - 1; i >= 0; i-- {
handler = middlewares[i](handler)
}
return handler
}