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

Internal redirects #82

Open
aturon opened this issue Nov 27, 2018 · 3 comments · Fixed by #450
Open

Internal redirects #82

aturon opened this issue Nov 27, 2018 · 3 comments · Fixed by #450
Labels
design Open design question feature A feature that's ready for implementation

Comments

@aturon
Copy link
Collaborator

aturon commented Nov 27, 2018

Since middleware and endpoints run strictly after routing (by design), we may want to provide an ergonomic way of internally redirecting to other routes.

Some considerations:

  • How best to express this? E.g. explicitly re-enter the router? Return a revised request? Something else?

  • How should middleware be applied when handling the redirected request?

@aturon aturon added design Open design question feature A feature that's ready for implementation labels Nov 27, 2018
@aturon
Copy link
Collaborator Author

aturon commented Nov 27, 2018

cc @wycats

@yoshuawuyts
Copy link
Member

We still don't support this currently. Incorrectly closed by #450.

@yoshuawuyts yoshuawuyts reopened this Apr 23, 2020
@yoshuawuyts
Copy link
Member

A possible API here could be:

async fn endpoint(req: Request<State>) -> tide::Result {
    Ok(req.redirect("/other/route").await?)
}

And then inside the redirect submodule we could implement redirect::internal similar to the other methods for a non-status code based redirect.

As far as the impl goes we should call the router again at the top-level, and then returning the response again. Either we pass a reference to the router along (preferable) or we can pass a bi-directional channel (less preferable).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Open design question feature A feature that's ready for implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants