summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs
index 0726f87..a83c1ae 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,13 +3,13 @@ extern crate tracing;
use color_eyre::eyre::Result;
use std::{net::IpAddr, sync::Arc};
-use warp::{Filter, path};
+use warp::{path, Filter};
use std::str::FromStr;
pub mod blog;
-pub mod misc;
mod internal;
+pub mod misc;
use internal::SiteState;
@@ -19,7 +19,6 @@ async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
info!("Starting launch of {}", env!("GIT_SHA"));
-
// Load .env
kankyo::init();
@@ -27,15 +26,19 @@ async fn main() -> Result<()> {
let index = warp::get().and(path::end().and_then(misc::handlers::index));
- let blog_index = warp::path!("blog").and(give_site_state(state.clone())).and_then(blog::handlers::list);
-
- let blog_post = warp::path!("blog" / String).and(give_site_state(state.clone())).and_then(blog::handlers::post);
-
+ let blog_index = warp::path!("blog")
+ .and(give_site_state(state.clone()))
+ .and_then(blog::handlers::list);
+ let blog_post = warp::path!("blog" / String)
+ .and(give_site_state(state.clone()))
+ .and_then(blog::handlers::post);
- let static_files = warp::path("static")
- .and(warp::fs::dir("./statics"));
- let site = index.or(blog_index.or(blog_post)).or(static_files).with(warp::log("site"));
+ let static_files = warp::path("static").and(warp::fs::dir("./statics"));
+ let site = index
+ .or(blog_index.or(blog_post))
+ .or(static_files)
+ .with(warp::log("site"));
let server = warp::serve(site);
@@ -51,7 +54,9 @@ async fn main() -> Result<()> {
Ok(())
}
-fn give_site_state(sitestate: Arc<SiteState>) -> impl Filter<Extract = (Arc<SiteState>,), Error=std::convert::Infallible> + Clone {
+fn give_site_state(
+ sitestate: Arc<SiteState>,
+) -> impl Filter<Extract = (Arc<SiteState>,), Error = std::convert::Infallible> + Clone {
warp::any().map(move || sitestate.clone())
}