From f3f5e03651e27c2bb5492ac50b6ae91a9336411c Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Sat, 28 Jan 2023 13:14:53 -0500 Subject: docker --- src/types/response.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/types') diff --git a/src/types/response.rs b/src/types/response.rs index de572b2..d10bce9 100644 --- a/src/types/response.rs +++ b/src/types/response.rs @@ -54,21 +54,21 @@ impl ResponseCode { } #[instrument()] - pub async fn file(self, path: &str) -> Result { + pub async fn file(self, path: &str) -> Response { if path.chars().position(|c| c == '.' ).is_none() { - return Err(ResponseCode::BadRequest.text("Folders cannot be served")); + return ResponseCode::BadRequest.text("Folders cannot be served"); } let path = format!("public{}", path); let svc = ServeFile::new(path); let Ok(mut res) = svc.oneshot(Request::new(Body::empty())).await else { tracing::error!("Error while fetching file"); - return Err(ResponseCode::InternalServerError.text("Error while fetching file")); + return ResponseCode::InternalServerError.text("Error while fetching file"); }; if res.status() != StatusCode::OK { - return Err(ResponseCode::NotFound.text("File not found")); + return ResponseCode::NotFound.text("File not found"); } *res.status_mut() = self.code(); - Ok(res.into_response()) + res.into_response() } } -- cgit v1.2.3-freya