mirror of
https://github.com/rwf2/Rocket.git
synced 2025-01-06 01:32:36 +00:00
83ffe0f7bc
This commit makes the `Config.secret_key` conditionally compile on the `secrets` feature. The net effect is simplified internal code, fewer corner-cases, and easier to write tests. This commit removes the `Provider::profile()` implementation of `Config`. This means that the `Config` provider no longer sets a profile, a likely confusing behavior. The `Config::figment()` continues to function as before.
32 lines
825 B
Rust
32 lines
825 B
Rust
#[macro_use] extern crate rocket;
|
|
|
|
use rocket::response::Redirect;
|
|
|
|
#[get("/google")]
|
|
fn google() -> Redirect {
|
|
Redirect::to("https://www.google.com")
|
|
}
|
|
|
|
#[get("/rocket")]
|
|
fn redirect() -> Redirect {
|
|
Redirect::to("https://rocket.rs:80")
|
|
}
|
|
|
|
mod test_absolute_uris_okay {
|
|
use super::*;
|
|
use rocket::local::blocking::Client;
|
|
|
|
#[test]
|
|
fn redirect_works() {
|
|
let client = Client::debug("/", routes![google, redirect]).unwrap();
|
|
|
|
let response = client.get("/google").dispatch();
|
|
let location = response.headers().get_one("Location");
|
|
assert_eq!(location, Some("https://www.google.com"));
|
|
|
|
let response = client.get("/rocket").dispatch();
|
|
let location = response.headers().get_one("Location");
|
|
assert_eq!(location, Some("https://rocket.rs:80"));
|
|
}
|
|
}
|