scratch uploaded file handler
This commit is contained in:
parent
3a2a49480c
commit
7d4f771b3d
|
@ -14,6 +14,7 @@ mod forms;
|
||||||
mod state;
|
mod state;
|
||||||
mod rejection;
|
mod rejection;
|
||||||
mod api;
|
mod api;
|
||||||
|
mod uploaded;
|
||||||
|
|
||||||
use state::SharedState;
|
use state::SharedState;
|
||||||
|
|
||||||
|
@ -23,7 +24,8 @@ pub fn routes(state: SharedState) -> impl Filter<Extract = impl Reply, Error = R
|
||||||
|
|
||||||
pages::get_routes(state.clone())
|
pages::get_routes(state.clone())
|
||||||
.or(forms::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(static_dir!("static"))
|
||||||
.or(warp::fs::dir(staticpath.to_string()))
|
.or(warp::fs::dir(staticpath.to_string()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
Loading…
Reference in New Issue