refactor: class rename and code format

This commit is contained in:
Vlad Stan 2022-11-29 18:19:33 +02:00
parent 598d2a6939
commit 8f8ebbeeaa
2 changed files with 6 additions and 5 deletions

View File

@ -27,8 +27,8 @@ from .core import core_app, core_app_extra
from .core.services import check_admin_settings
from .core.views.generic import core_html_routes
from .helpers import (
EnabledExtensionMiddleware,
Extension,
InstalledExtensionMiddleware,
get_css_vendored,
get_js_vendored,
get_valid_extensions,
@ -72,7 +72,7 @@ def create_app() -> FastAPI:
)
app.add_middleware(GZipMiddleware, minimum_size=1000)
app.add_middleware(EnabledExtensionMiddleware)
app.add_middleware(InstalledExtensionMiddleware)
register_startup(app)
register_assets(app)

View File

@ -80,7 +80,7 @@ class ExtensionManager:
return output
class EnabledExtensionMiddleware:
class InstalledExtensionMiddleware:
def __init__(self, app: ASGIApp) -> None:
self.app = app
@ -97,14 +97,15 @@ class EnabledExtensionMiddleware:
# re-route trafic if the extension has been upgraded
upgraded_extensions = list(
filter(
lambda ext: ext.endswith(f"/{pathname}"), g().config.LNBITS_UPGRADED_EXTENSIONS)
lambda ext: ext.endswith(f"/{pathname}"),
g().config.LNBITS_UPGRADED_EXTENSIONS,
)
)
if len(upgraded_extensions) != 0:
upgrade_path = upgraded_extensions[0]
tail = "/".join(rest)
scope["path"] = f"/upgrades/{upgrade_path}/{tail}"
await self.app(scope, receive, send)