Seems like lifetime proliferation
This commit is contained in:
parent
f45fa4df04
commit
f8a3f70d05
|
@ -580,7 +580,7 @@ impl Response {
|
|||
/// of a route to return a value for the route.
|
||||
///
|
||||
/// This will overwrite any existing CORS headers
|
||||
pub fn respond<'r>(&self, base: response::Response<'r>) -> response::Response<'r> {
|
||||
pub fn response<'r>(&self, base: response::Response<'r>) -> response::Response<'r> {
|
||||
let mut response = response::Response::build_from(base).finalize();
|
||||
self.merge(&mut response);
|
||||
response
|
||||
|
|
|
@ -8,6 +8,7 @@ extern crate rocket_cors as cors;
|
|||
|
||||
use std::str::FromStr;
|
||||
|
||||
use rocket::Response;
|
||||
use rocket::http::Method;
|
||||
use rocket::http::{Header, Status};
|
||||
use rocket::local::Client;
|
||||
|
@ -22,6 +23,29 @@ fn cors<'a>(cors: cors::Response) -> cors::Responder<'a, &'a str> {
|
|||
cors.responder("Hello CORS")
|
||||
}
|
||||
|
||||
// The following routes tests that the routes can be compiled with ad-hoc CORS Response/Responders
|
||||
|
||||
/// Using a `Response` instead of a `Responder`
|
||||
#[allow(unmounted_route)]
|
||||
#[get("/")]
|
||||
fn response<'a>(cors: cors::Response) -> Response<'a> {
|
||||
cors.response(Response::new())
|
||||
}
|
||||
|
||||
/// `Responder` with String
|
||||
#[allow(unmounted_route)]
|
||||
#[get("/")]
|
||||
fn responder_string<'a>(cors: cors::Response) -> cors::Responder<'a, String> {
|
||||
cors.responder("Hello CORS".to_string())
|
||||
}
|
||||
|
||||
/// `Responder` with 'static ()
|
||||
#[allow(unmounted_route)]
|
||||
#[get("/")]
|
||||
fn responder_unit(cors: cors::Response) -> cors::Responder<'static, ()> {
|
||||
cors.responder(())
|
||||
}
|
||||
|
||||
fn make_cors_options() -> cors::Cors {
|
||||
let (allowed_origins, failed_origins) =
|
||||
cors::AllOrSome::new_from_str_list(&["https://www.acme.com"]);
|
||||
|
|
Loading…
Reference in New Issue