Skip to content

Commit

Permalink
revert exposing router_class
Browse files Browse the repository at this point in the history
  • Loading branch information
devkral committed Jan 2, 2025
1 parent 97afe9d commit 4917912
Show file tree
Hide file tree
Showing 3 changed files with 610 additions and 619 deletions.
3 changes: 0 additions & 3 deletions docs/en/docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ hide:
### Added

- Add `ReceiveSendSniffer`. This sniffer allows to detect communication events and to replay receive messages.
- `Include` and `BaseLilya` (application) have now a ClassVar `router_class` to provide a custom router.
- Subclasses of `BaseLilya` (application) can set the `router_class` to None to provide a completely custom router
which initialization parameters aren't required to match the ones of `Router`.
- Expose `fall_through` on `StaticFile`.

### Changed
Expand Down
26 changes: 11 additions & 15 deletions lilya/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from collections.abc import Awaitable, Callable, Mapping, Sequence
from functools import cached_property
from typing import Annotated, Any, ClassVar, cast
from typing import Annotated, Any, cast

from lilya._internal._module_loading import import_string
from lilya._utils import is_class_and_subclass
Expand Down Expand Up @@ -44,9 +44,6 @@


class BaseLilya:
router_class: ClassVar[type[Router] | None] = Router
router: Router

def __init__(
self,
debug: Annotated[bool, Doc("Enable or disable debug mode. Defaults to False.")] = False,
Expand Down Expand Up @@ -395,17 +392,16 @@ async def create_user(request: Request):
self.state = State()
self.middleware_stack: ASGIApp | None = None

if self.router_class is not None:
self.router = self.router_class(
routes=routes,
redirect_slashes=redirect_slashes,
permissions=self.custom_permissions,
on_startup=on_startup,
on_shutdown=on_shutdown,
lifespan=lifespan,
include_in_schema=include_in_schema,
settings_module=self.settings,
)
self.router: Router = Router(
routes=routes,
redirect_slashes=redirect_slashes,
permissions=self.custom_permissions,
on_startup=on_startup,
on_shutdown=on_shutdown,
lifespan=lifespan,
include_in_schema=include_in_schema,
settings_module=self.settings,
)
self.__set_settings_app(self.settings, self)

@property
Expand Down
Loading

0 comments on commit 4917912

Please sign in to comment.