diff options
Diffstat (limited to 'src/types')
-rw-r--r-- | src/types/response.rs | 10 |
1 files changed, 5 insertions, 5 deletions
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<Response> { + 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() } } |