The function route_reverse
does not parse query parameters, adding that would be very useful.
The following example has a single router at /
with two query parameters p
and q
but the route_reverse
method does not add them.
A request to /
returns just Hello, World at /
which is not correct, it should return Hello, World at /?q=1
. A request to /?p=1
should return Hello, World at /?p=1&q=1
, i.e. the function should deal gracefully with the default values as well.
from litestar import Litestar, get, Request
@get("/", name="hello_world")
async def hello_world(request: Request, p: int = 0, q: int = 0) -> str:
path = request.app.route_reverse("hello_world", p=p, q=q+1)
return f"Hello, World at {path}"
app = Litestar([hello_world])
Maybe people rely on the method not returning the query params. A flag controlling the removal of query parameters could be added for them.
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too