aboutsummaryrefslogtreecommitdiff
path: root/src/routes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes.rs')
-rw-r--r--src/routes.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/routes.rs b/src/routes.rs
index 509f1b2..ca1cc41 100644
--- a/src/routes.rs
+++ b/src/routes.rs
@@ -33,13 +33,9 @@ pub async fn routes(
match (request.method(), path_parts) {
(&Method::GET, []) => Ok(html(templates::INDEX)),
- (&Method::GET, ["static", "main.js"]) =>
- Ok(static_file(MAIN_JS, "application/javascript")),
- (&Method::GET, ["static", "icon.png"]) =>
- Ok(static_file(ICON_PNG, "image/png")),
- (&Method::GET, ["static", "main.css"]) => {
- Ok(static_file(MAIN_CSS, "text/css"))
- }
+ (&Method::GET, ["static", "main.js"]) => Ok(static_file(MAIN_JS, "application/javascript")),
+ (&Method::GET, ["static", "icon.png"]) => Ok(static_file(ICON_PNG, "image/png")),
+ (&Method::GET, ["static", "main.css"]) => Ok(static_file(MAIN_CSS, "text/css")),
(&Method::POST, ["upload"]) => {
upload_file(request, db_conn, authorized_key, files_dir).await
}
@@ -134,9 +130,7 @@ async fn get(
) -> Result<Response<BoxBody<Bytes, std::io::Error>>> {
let file = db::files::get(&db_conn, file_id).await;
match (get_file, file) {
- (GetFile::ShowPage, Ok(Some(file))) => {
- Ok(html(templates::file_page(file)))
- },
+ (GetFile::ShowPage, Ok(Some(file))) => Ok(html(templates::file_page(file))),
(GetFile::Download, Ok(Some(file))) => {
let path = files_dir.join(file_id);
Ok(stream_file(path, file).await)
@@ -150,7 +144,7 @@ async fn get(
}
fn static_file(
- content: &'static[u8],
+ content: &'static [u8],
content_type: &str,
) -> Response<BoxBody<Bytes, std::io::Error>> {
let response = Response::builder()
@@ -204,7 +198,9 @@ fn html(text: impl Into<String>) -> Response<BoxBody<Bytes, std::io::Error>> {
html_response(response(StatusCode::OK, text))
}
-fn html_response(response: Response<BoxBody<Bytes, std::io::Error>>) -> Response<BoxBody<Bytes, std::io::Error>> {
+fn html_response(
+ response: Response<BoxBody<Bytes, std::io::Error>>,
+) -> Response<BoxBody<Bytes, std::io::Error>> {
with_headers(response, vec![(CONTENT_TYPE, "text/html")])
}