Skip to content

Commit

Permalink
Merge pull request #92 from mprasil/not_found
Browse files Browse the repository at this point in the history
Return 404 in case the path doesn't match instead of 500
  • Loading branch information
dani-garcia authored Jul 18, 2018
2 parents 798a3b6 + 2dc1427 commit 48e69ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bitwarden_rs"
version = "0.10.0"
version = "0.11.0"
authors = ["Daniel García <[email protected]>"]

[dependencies]
Expand Down
21 changes: 13 additions & 8 deletions src/api/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
use rocket::request::Request;
use rocket::response::{self, NamedFile, Responder};
use rocket::response::content::Content;
use rocket::http::ContentType;
use rocket::http::{ContentType, Status};
use rocket::Route;
use rocket_contrib::{Json, Value};

Expand Down Expand Up @@ -49,14 +49,19 @@ struct WebHeaders<R>(R);

impl<'r, R: Responder<'r>> Responder<'r> for WebHeaders<R> {
fn respond_to(self, req: &Request) -> response::Result<'r> {
let mut res = self.0.respond_to(req)?;
match self.0.respond_to(req) {
Ok(mut res) => {
res.set_raw_header("Referrer-Policy", "same-origin");
res.set_raw_header("X-Frame-Options", "SAMEORIGIN");
res.set_raw_header("X-Content-Type-Options", "nosniff");
res.set_raw_header("X-XSS-Protection", "1; mode=block");

res.set_raw_header("Referrer-Policy", "same-origin");
res.set_raw_header("X-Frame-Options", "SAMEORIGIN");
res.set_raw_header("X-Content-Type-Options", "nosniff");
res.set_raw_header("X-XSS-Protection", "1; mode=block");

Ok(res)
Ok(res)
},
Err(_) => {
Err(Status::NotFound)
}
}
}
}

Expand Down

0 comments on commit 48e69ce

Please sign in to comment.