aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs
index 99956c3..276a3e2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -200,12 +200,9 @@ async fn service<C: Controller>(
let mut resp = build_response(args, &*controller, parts, body)
.await
.unwrap_or_else(|err| {
- if let Some(resp) = controller.before_return_error(&err) {
- return resp;
- }
let (status, message) = match err {
Error::BadRequest(msg) => (400, msg),
- Error::Unauthorized(msg, _ctx) => (401, msg),
+ Error::Unauthorized(msg) => (401, msg),
Error::Forbidden(msg) => (403, msg),
Error::NotFound(msg) => (404, msg),
Error::Internal(msg) => (500, msg),
@@ -322,11 +319,11 @@ async fn build_response<C: Controller>(
let repo = Repository::open_bare(env::current_dir().unwrap()).unwrap();
- if let Some(resp) = controller.before_route(&parts, &repo) {
- return resp;
- }
-
- let (rev, unsanitized_path) = controller.parse_url_path(&unsanitized_path)?;
+ let (rev, unsanitized_path) = match controller.parse_url_path(&unsanitized_path, &parts, &repo)
+ {
+ Ok(parsed) => parsed,
+ Err(res) => return res,
+ };
let mut comps = Vec::new();
@@ -355,7 +352,6 @@ async fn build_response<C: Controller>(
if !controller.may_read_path(&ctx) {
return Err(Error::Unauthorized(
"you are not authorized to view this file".into(),
- ctx,
));
}