Skip to content

Commit

Permalink
fix(docs): update url to path in Redirect to resolve #2407 (
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobCoffee authored Oct 7, 2023
1 parent 2222d2d commit 13e6977
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/migration/flask.rst
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ For redirects, instead of ``redirect`` use ``Redirect``:
@get("/hello")
def hello() -> Redirect:
return Redirect(url="index")
return Redirect(path="index")
app = Litestar([index, hello])
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/middleware/creating-middleware.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ explore another example - redirecting the request to a different url from a midd
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
if Request(scope).session is None:
response = Redirect(url="/login")
response = Redirect(path="/login")
await response(scope, receive, send)
else:
await self.app(scope, receive, send)
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/responses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ In Litestar, a redirect response looks like this:
# do some stuff here
# ...
# finally return redirect
return Redirect(url="/other-path")
return Redirect(path="/other-path")
To return a redirect response you should do the following:

Expand Down
4 changes: 2 additions & 2 deletions docs/usage/routing/handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,13 @@ it can be used to build a URL path for that handler:
# do something with the handler index below, e.g. send a redirect response to the handler, or access
# handler.opt and some values stored there etc.
return Redirect(url=handler_index[0])
return Redirect(path=handler_index[0])
@get("/redirect/{param_value:int}", name="five")
def handler_five(request: Request, param_value: int) -> Redirect:
path = request.app.route_reverse("three", param=param_value)
return Redirect(url=path)
return Redirect(path=path)
app = Litestar(route_handlers=[handler_one, handler_two, handler_three])
Expand Down

0 comments on commit 13e6977

Please sign in to comment.