Julio Biason
5 months ago
6 changed files with 102 additions and 2 deletions
@ -0,0 +1,26 @@ |
|||||||
|
//! Static file serving
|
||||||
|
|
||||||
|
use axum::body::Body; |
||||||
|
use axum::extract::Path; |
||||||
|
use axum::http::header; |
||||||
|
use axum::http::StatusCode; |
||||||
|
use axum::response::Response; |
||||||
|
use phf::phf_map; |
||||||
|
|
||||||
|
static FILES: phf::Map<&'static str, &'static str> = phf_map! { |
||||||
|
"main.css" => include_str!("../../staticfiles/main.css") |
||||||
|
}; |
||||||
|
|
||||||
|
pub(super) async fn staticfile(Path(filename): Path<String>) -> Response { |
||||||
|
match FILES.get(&filename) { |
||||||
|
Some(content) => Response::builder() |
||||||
|
.status(StatusCode::OK) |
||||||
|
.header(header::CONTENT_TYPE, "text/css") |
||||||
|
.body(Body::from(*content)) |
||||||
|
.unwrap(), |
||||||
|
None => Response::builder() |
||||||
|
.status(StatusCode::NOT_FOUND) |
||||||
|
.body(Body::from("Not found")) |
||||||
|
.unwrap(), |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
/* main */ |
||||||
|
body { |
||||||
|
background-color: #14142E; |
||||||
|
color: #ffffff; |
||||||
|
} |
Loading…
Reference in new issue