Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docs): update url to path in Redirect to resolve #2407 #2410

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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