Skip to content

Commit

Permalink
refactor notes and passes
Browse files Browse the repository at this point in the history
  • Loading branch information
devkral committed Nov 9, 2024
1 parent 129a913 commit ed523ca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/en/docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ hide:
- Breaking: The `add_pluggable` method is now renamed to `add_extension`. The old name is still available but deprecated.
- The documentation will refer now to extensions with `Pluggable` as a setup wrapper.
- Allow passing HTTP/WebSocket handlers directly to routes. They are automatically wrapped in Gateways-
- Allow passing HTTP/WebSocket handlers directly to routes as alternative to defining a Gateway/WebsocketGateway.

## 3.4.4

Expand Down
6 changes: 3 additions & 3 deletions docs/en/docs/routing/routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ different APIs and systems, so Esmerald created its own.
A Gateway is an extension of the Route, really, but adds its own logic and handling capabilities, as well as its own
validations, without compromising the core.

It is automatically added when just passing an HTTP/Websocket handler to routes.
When a handler is passed instead of a Gateway/WebsocketGateway, it will be automatically mapped to the corresponding wrapper and added to the routes.

### Gateway and application

In simple terms, a Gateway is not a direct route but instead is a "wrapper" of a [handler](./handlers.md)
and maps that same handler with the application routing system.

This allows overwriting options of the handler route specific.
This allows overwriting options of the specific handler route.
If not required, you can just pass the handler, it is automatically wrapped in a plain Gateway.

#### Parameters
Expand All @@ -41,7 +41,7 @@ All the parameters and defaults are available in the [Gateway Reference](../refe
Same principle as [Gateway](#gateway) with one particularity. Due to the nature of Lilya and websockets we
decided not to interfere (for now) with what already works and therefore the only supported websockets are `async`.

This allows overwriting options of the WebsocketHandler route specific.
This allows overwriting options of the specific WebsocketHandler route.
If not required, you can just pass the handler, it is automatically wrapped in a plain WebSocketGateway.

### WebSocketGateway and application
Expand Down
4 changes: 2 additions & 2 deletions esmerald/routing/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ async def another(request: Request) -> str:
for route in routes or []:
if isinstance(route, WebhookHandler):
# WebhookHandler is a subclass of HTTPHandler, make sure to not upgrade it
pass
...
elif isinstance(route, HTTPHandler):
# if using add_route, we would enter a completely different code path with a not fully initialized router
route = Gateway(handler=route)
Expand Down Expand Up @@ -2915,7 +2915,7 @@ def resolve_route_path_handler(
for route in routes: # pragma: no cover
if isinstance(route, WebhookHandler):
# fail later, a WebhookHandler is subclass of HTTPHandler, so pass down
pass
...
elif isinstance(route, HTTPHandler):
# if using add_route, we would enter a completely different code path with a not fully initialized router
route = Gateway(handler=route)
Expand Down

0 comments on commit ed523ca

Please sign in to comment.