aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs37
1 files changed, 1 insertions, 36 deletions
diff --git a/src/main.rs b/src/main.rs
index 513f59e..231a7af 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -21,7 +21,6 @@ use serde::Deserialize;
use sputnik::html_escape;
use sputnik::mime;
use sputnik::request::SputnikParts;
-use sputnik::response::EmptyBuilder;
use sputnik::response::SputnikBuilder;
use std::convert::Infallible;
use std::env;
@@ -252,41 +251,7 @@ async fn service<C: Controller>(
.unwrap()
}
})
- .unwrap_or_else(|err| {
- let (status, message) = match err {
- Error::BadRequest(msg) => (400, msg),
- Error::Unauthorized(msg) => (401, msg),
- Error::Forbidden(msg) => (403, msg),
- Error::NotFound(msg) => (404, msg),
- Error::Internal(msg) => (500, msg),
- Error::NotModified => {
- return Builder::new()
- .status(StatusCode::NOT_MODIFIED)
- .empty()
- .unwrap();
- }
- Error::MissingTrailingSlash(path) => {
- return Builder::new()
- .status(StatusCode::FOUND)
- .header("location", format!("{}/", path))
- .body("redirecting".into())
- .unwrap();
- }
- Error::Redirect(target) => {
- return Builder::new()
- .status(StatusCode::FOUND)
- .header("location", target)
- .body("redirecting".into())
- .unwrap();
- }
- };
- // TODO: use Page
- Builder::new()
- .status(status)
- .header("content-type", "text/html")
- .body(message.into())
- .unwrap()
- });
+ .unwrap_or_else(|err| err.into());
// we rely on CSP to thwart XSS attacks, all modern browsers support it
resp.headers_mut()