Open aturon opened 6 years ago
cc @wycats
We still don't support this currently. Incorrectly closed by #450.
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).
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?