summaryrefslogtreecommitdiff
path: root/src/types
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2023-01-28 13:14:53 -0500
committerTyler Murphy <tylermurphy534@gmail.com>2023-01-28 13:14:53 -0500
commitf3f5e03651e27c2bb5492ac50b6ae91a9336411c (patch)
treef23f1e3bc2c1007ccdd9fd64b3df0f316c868e26 /src/types
parenttracing (diff)
downloadxssbook-f3f5e03651e27c2bb5492ac50b6ae91a9336411c.tar.gz
xssbook-f3f5e03651e27c2bb5492ac50b6ae91a9336411c.tar.bz2
xssbook-f3f5e03651e27c2bb5492ac50b6ae91a9336411c.zip
docker
Diffstat (limited to 'src/types')
-rw-r--r--src/types/response.rs10
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()
}
}