scratch uploaded file handler

This commit is contained in:
blek 2023-10-10 22:04:15 +10:00
parent 3a2a49480c
commit 7d4f771b3d
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,7 @@ mod forms;
mod state;
mod rejection;
mod api;
mod uploaded;
use state::SharedState;
@ -23,7 +24,8 @@ pub fn routes(state: SharedState) -> impl Filter<Extract = impl Reply, Error = R
pages::get_routes(state.clone())
.or(forms::get_routes(state.clone()))
.or(api::get_routes(state))
.or(api::get_routes(state.clone()))
.or(uploaded::get_uploaded(state))
.or(static_dir!("static"))
.or(warp::fs::dir(staticpath.to_string()))
}

13
filed/src/web/uploaded.rs Normal file
View File

@ -0,0 +1,13 @@
use warp::{Filter, reply::{Reply, html}, reject::Rejection};
use super::state::SharedState;
pub async fn uploaded((file, _state): (String, SharedState)) -> Result<Box<dyn Reply>, Rejection> {
Ok(Box::new(html(file)))
}
pub fn get_uploaded(state: SharedState) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
warp::path!("upload" / String)
.map(move |x| (x, state.clone()))
.and_then(uploaded)
}