i did some stuff
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -16,8 +16,13 @@ use smol::{fs, io, prelude::*, Async, Executor};
|
||||
use smol_hyper::rt::{FuturesIo, SmolTimer};
|
||||
use smol_macros::main;
|
||||
|
||||
mod assets;
|
||||
mod loader;
|
||||
mod page;
|
||||
|
||||
use crate::assets::AssetStore;
|
||||
use crate::loader::*;
|
||||
use crate::page::*;
|
||||
|
||||
struct AppState<'a> {
|
||||
pub pages: Vec<Page>,
|
||||
@@ -41,14 +46,21 @@ async fn serve(req: Request<Incoming>, state: Arc<AppState<'_>>) -> Result<Respo
|
||||
false
|
||||
}
|
||||
});
|
||||
let reply = match mreow {
|
||||
let reply: Bytes = match mreow {
|
||||
Some(x) => state
|
||||
.env
|
||||
.get_template(&x.header.id)
|
||||
.unwrap()
|
||||
.render(context! {})
|
||||
.unwrap(),
|
||||
None => "?".to_string(),
|
||||
.unwrap()
|
||||
.into(),
|
||||
None => match AssetStore::new("./templateServe/_assets/".into())
|
||||
.load_asset(path)
|
||||
.await
|
||||
{
|
||||
Ok(asset) => asset,
|
||||
Err(_) => "".into(),
|
||||
},
|
||||
};
|
||||
Ok(Response::new(Full::new(reply.into())))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user