rocket 0.5-rc2 & rust 1.64

This commit is contained in:
2022-09-23 12:47:06 +08:00
parent 2bae66099d
commit 791d1f526d
12 changed files with 30 additions and 29 deletions

View File

@@ -19,11 +19,11 @@ impl Fairing for Cors {
}
async fn on_response<'r>(&self, request: &'r Request<'_>, response: &mut Response<'r>) {
if let Some(origin) = request
.headers()
.get_one("Origin")
.and_then(|origin| self.whitelist.contains(&origin.to_string()).then(|| origin))
{
if let Some(origin) = request.headers().get_one("Origin").and_then(|origin| {
self.whitelist
.contains(&origin.to_string())
.then_some(origin)
}) {
response.set_header(Header::new("Access-Control-Allow-Origin", origin));
response.set_header(Header::new(
"Access-Control-Allow-Methods",