aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorXe Iaso <me@christine.website>2022-12-28 12:14:08 -0500
committerXe Iaso <me@christine.website>2022-12-28 12:14:08 -0500
commitb292f3830e43830308ebd8e8d17ab38e9ed2461b (patch)
tree951d70bbdbc1592d1984d322bec9cdbaaf558d59 /src/main.rs
parent3299a4fa2a58ba07b182b9f169493ba33dfbd6bb (diff)
downloadxesite-b292f3830e43830308ebd8e8d17ab38e9ed2461b.tar.xz
xesite-b292f3830e43830308ebd8e8d17ab38e9ed2461b.zip
Update to axum 0.6
Closes #579 Closes #580 Signed-off-by: Xe <me@christine.website>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs24
1 files changed, 5 insertions, 19 deletions
diff --git a/src/main.rs b/src/main.rs
index 737ab45..3952975 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -10,6 +10,7 @@ use axum::{
routing::{get, get_service},
Router,
};
+use axum_extra::routing::SpaRouter;
use color_eyre::eyre::Result;
use hyper::StatusCode;
use prometheus::{Encoder, TextEncoder};
@@ -104,6 +105,8 @@ async fn main() -> Result<()> {
))
.layer(CorsLayer::permissive());
+ let files = SpaRouter::new("/static", "static");
+
let app = Router::new()
// meta
.route("/.within/health", get(healthcheck))
@@ -194,25 +197,8 @@ async fn main() -> Result<()> {
// junk google wants
.route("/sitemap.xml", get(handlers::feeds::sitemap))
// static files
- .nest(
- "/css",
- get_service(ServeDir::new("./css")).handle_error(|err: io::Error| async move {
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- format!("unhandled internal server error: {}", err),
- )
- }),
- )
- .nest(
- "/static",
- get_service(ServeDir::new("./static")).handle_error(|err: io::Error| async move {
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- format!("unhandled internal server error: {}", err),
- )
- }),
- )
- .fallback(handlers::not_found.into_service())
+ .merge(files)
+ .fallback(handlers::not_found)
.layer(middleware);
#[cfg(target_os = "linux")]