-
Notifications
You must be signed in to change notification settings - Fork 157
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
How do I respond with redirects? #221
Comments
use hyper::header::Location;
use nickel::status::StatusCode;
... middleware! { |request, mut response|
response.origin.headers_mut().set(Location("https://...".into()));
(StatusCode::TemporaryRedirect, "")
} Will be cleaner once #217 lands: Ryman@37482ad. As we evolve I'm sure we'll develop a shorthand for this scenario, e.g. If you have any other feedback on that thread that's also appreciated! |
I get this error when trying it using the built in Location header. I got to this point before, and ended up doing it the other way. Am I missing some trait usings? My Cargo.toml looks like: [package]
name = "schedule-gen-web"
version = "0.0.1"
authors = ["Ethan Frei <[email protected]>"]
[dependencies.nickel]
git = "https://github.com/nickel-org/nickel.rs.git"
[dependencies.schedule_gen]
git = "https://github.com/freiguy1/schedule-gen-rs"
[dependencies]
rustc-serialize = "*"
hyper = "*"
|
Does it compile if you set |
That did build and work! Thanks. |
I got this:
|
it should be just Or even, |
woah, that's was quick.
|
It should be :) |
I'm manually returning a redirect response by directly manipulating the header, but I do not like the way I'm doing so:
What's the preferred way to redirect? The last time I checked, some code for redirecting in examples was commented out.
The text was updated successfully, but these errors were encountered: