actix-web-lab icon indicating copy to clipboard operation
actix-web-lab copied to clipboard

Dynamic redirecting

Open letto4135 opened this issue 2 years ago • 1 comments

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/**")

letto4135 avatar Jun 28 '22 17:06 letto4135

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.

robjtede avatar Jul 03 '22 01:07 robjtede