diff --git a/filed/src/web/api.rs b/filed/src/web/api.rs new file mode 100644 index 0000000..fe94ecc --- /dev/null +++ b/filed/src/web/api.rs @@ -0,0 +1,18 @@ +use warp::{reply::Reply, reject::Rejection, Filter}; + +use super::state::SharedState; + +mod get_all; + +pub fn api_root() -> Box { + Box::new(warp::reply::json(&String::from("{ error: \"You have called the API root of a blek! File instance. Refer to https://git.blek.codes/blek/bfile.git for documentation.\" }"))) +} + +pub fn get_routes(state: SharedState) -> impl Filter + Clone { + let api = warp::path!("api"); + let api = api + .and(warp::path::end()) + .map(api_root) + .or(get_all::get_all_f(state)); + api +} \ No newline at end of file diff --git a/filed/src/web/api/get_all.rs b/filed/src/web/api/get_all.rs new file mode 100644 index 0000000..6e06b91 --- /dev/null +++ b/filed/src/web/api/get_all.rs @@ -0,0 +1,13 @@ +use warp::{reply::Reply, reject::Rejection, Filter}; + +use crate::web::state::SharedState; + +pub async fn get_all(_state: SharedState) -> Result, Rejection> { + Ok(Box::new(warp::reply::json(&String::from("aaaaa")))) +} + +pub fn get_all_f(state: SharedState) -> impl Filter + Clone { + warp::path!("get_all") + .map(move || state.clone()) + .and_then(get_all) +} \ No newline at end of file diff --git a/filed/src/web/mod.rs b/filed/src/web/mod.rs index df4ebad..ef45ce9 100644 --- a/filed/src/web/mod.rs +++ b/filed/src/web/mod.rs @@ -12,6 +12,7 @@ mod pages; mod forms; mod state; mod rejection; +mod api; use state::SharedState; @@ -20,7 +21,8 @@ pub fn routes(state: SharedState) -> impl Filter