From 65b59f6117b65d5ff204c91202ea33b066440289 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 28 Mar 2022 01:52:11 +0100 Subject: [PATCH] Revert "resource leaf routing: Attempt via impl FromRequest" This reverts commit 383fab0156489a705901ba06580c60215dc313c6. --- daemon/main.rs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/daemon/main.rs b/daemon/main.rs index 9e59add4..d19f0a28 100644 --- a/daemon/main.rs +++ b/daemon/main.rs @@ -129,23 +129,6 @@ struct CheckedResourceLeaf { #[error("not a valid resource path")] struct UnknownResource; -impl ResponseError for UnknownResource { - fn status_code(&self) -> StatusCode { StatusCode::NOT_FOUND } - fn error_response(&self) -> HttpResponse { error_response(self) } -} - -// Magically looks for "{leaf}" -impl FromRequest for CheckedResourceLeaf { - type Error = UnknownResource; - type Future = future::Ready>; - fn from_request(req: &HttpRequest, _: &mut actix_web::dev::Payload) - -> Self::Future { - future::ready( - req.match_info().query("leaf").parse() - ) - } -} - impl FromStr for CheckedResourceLeaf { type Err = UnknownResource; fn from_str(s: &str) -> Result { @@ -315,7 +298,8 @@ async fn updates_route(query: Query) -> impl Responder { #[route("/_/{leaf}", method="GET", method="HEAD")] #[throws(io::Error)] -async fn resource(leaf: CheckedResourceLeaf) -> impl Responder { +async fn resource(leaf: Path>) -> impl Responder { + let leaf = leaf.into_inner().0; let path = match leaf.locn { RL::Main => format!("{}/{}", config().template_dir, leaf.safe_leaf), RL::Wasm(s) => format!("{}/{}", config().wasm_dir, s), -- 2.30.2