1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-05-22 19:43:57 +00:00

Merge pull request #1546 from RealOrangeOne/clippy-run

Run Clippy
This commit is contained in:
Daniel García 2021-03-28 16:04:09 +02:00 committed by GitHub
commit fd27759a95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 176 additions and 167 deletions

View file

@ -38,9 +38,9 @@ impl Fairing for AppHeaders {
}
}
pub struct CORS();
pub struct Cors();
impl CORS {
impl Cors {
fn get_header(headers: &HeaderMap, name: &str) -> String {
match headers.get_one(name) {
Some(h) => h.to_string(),
@ -51,7 +51,7 @@ impl CORS {
// Check a request's `Origin` header against the list of allowed origins.
// If a match exists, return it. Otherwise, return None.
fn get_allowed_origin(headers: &HeaderMap) -> Option<String> {
let origin = CORS::get_header(headers, "Origin");
let origin = Cors::get_header(headers, "Origin");
let domain_origin = CONFIG.domain_origin();
let safari_extension_origin = "file://";
if origin == domain_origin || origin == safari_extension_origin {
@ -62,10 +62,10 @@ impl CORS {
}
}
impl Fairing for CORS {
impl Fairing for Cors {
fn info(&self) -> Info {
Info {
name: "CORS",
name: "Cors",
kind: Kind::Response,
}
}
@ -73,14 +73,14 @@ impl Fairing for CORS {
fn on_response(&self, request: &Request, response: &mut Response) {
let req_headers = request.headers();
if let Some(origin) = CORS::get_allowed_origin(req_headers) {
if let Some(origin) = Cors::get_allowed_origin(req_headers) {
response.set_header(Header::new("Access-Control-Allow-Origin", origin));
}
// Preflight request
if request.method() == Method::Options {
let req_allow_headers = CORS::get_header(req_headers, "Access-Control-Request-Headers");
let req_allow_method = CORS::get_header(req_headers, "Access-Control-Request-Method");
let req_allow_headers = Cors::get_header(req_headers, "Access-Control-Request-Headers");
let req_allow_method = Cors::get_header(req_headers, "Access-Control-Request-Method");
response.set_header(Header::new("Access-Control-Allow-Methods", req_allow_method));
response.set_header(Header::new("Access-Control-Allow-Headers", req_allow_headers));