summaryrefslogtreecommitdiff
path: root/src/types/http.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/types/http.rs')
-rw-r--r--src/types/http.rs23
1 files changed, 1 insertions, 22 deletions
diff --git a/src/types/http.rs b/src/types/http.rs
index 8524b15..06674ca 100644
--- a/src/types/http.rs
+++ b/src/types/http.rs
@@ -1,11 +1,8 @@
use axum::{
- body::Body,
headers::HeaderName,
- http::{HeaderValue, Request, StatusCode},
+ http::{HeaderValue, StatusCode},
response::{IntoResponse, Response},
};
-use tower::ServiceExt;
-use tower_http::services::ServeFile;
use tracing::instrument;
#[derive(Debug)]
@@ -58,24 +55,6 @@ impl ResponseCode {
);
res
}
-
- #[instrument()]
- pub async fn file(self, path: &str) -> Response {
- if !path.chars().any(|c| c == '.') {
- return Self::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 Self::InternalServerError.text("Error while fetching file");
- };
- if res.status() != StatusCode::OK {
- return Self::NotFound.text("File not found");
- }
- *res.status_mut() = self.code();
- res.into_response()
- }
}
pub type Result<T> = std::result::Result<T, Response>;