actix-web-lab
actix-web-lab copied to clipboard
Dynamic redirecting
The docs show that you can do this
// redirects "/oh/hi/mark" to "/oh/bye/mark"
Redirect::new("/oh/hi/mark", "../../bye/mark");
A nice thing to be able to do would be would be more dynamic redirects. Examples:
// redirects "/redirect/me/to/here" to "https://hello.com/me/to/here"
Redirect::new("/redirect", "https://hello.com/../../..")
// redirects "/redirectme/tohere" to https://hello.com/tohere"
Redirect::new("/redirectme", "https://hello.com/..")
// redirects /redirect/me/to/here to "https://hello.com/redirect/me/to/here"
Redirect::new("/redirectme", "https://hello.com/**")
The redirect service does not pattern match.
The example:
Redirect::new("/oh/hi/mark", "../../bye/mark");
literally sends the header Location: ../../bye/mark
back to the client. It is up to them to resolve this and make the follow-up request.
I can see the use case for a more dynamic redirect system that does match patterns. If this is what you are looking for, I'd suggest re-wording the issue and we can turn this into a feature request.
Regarding preserving body, it is irrelevant because this is not intended to be a proxy. It only serves redirect responses.