aboutsummaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/util.rs b/src/util.rs
index de663583..06984c78 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -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));