diff --git a/filed/src/web/api.rs b/filed/src/web/api.rs index fe94ecc..5edfff9 100644 --- a/filed/src/web/api.rs +++ b/filed/src/web/api.rs @@ -1,18 +1,27 @@ use warp::{reply::Reply, reject::Rejection, Filter}; +use serde::{Serialize, Deserialize}; + +use self::get_all::get_all_f; use super::state::SharedState; mod get_all; +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct APIError { + error: String +} + 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.\" }"))) + let err = APIError { + error: "You have called the API root of a blek! File instance. Refer to https://git.blek.codes/blek/bfile.git for documentation.".into() + }; + Box::new(warp::reply::json(&err)) } pub fn get_routes(state: SharedState) -> impl Filter + Clone { - let api = warp::path!("api"); - let api = api + warp::path!("api") .and(warp::path::end()) .map(api_root) - .or(get_all::get_all_f(state)); - api + .or(get_all_f(state)) } \ No newline at end of file diff --git a/filed/src/web/api/get_all.rs b/filed/src/web/api/get_all.rs index 6e06b91..72879e6 100644 --- a/filed/src/web/api/get_all.rs +++ b/filed/src/web/api/get_all.rs @@ -7,7 +7,7 @@ pub async fn get_all(_state: SharedState) -> Result, Rejection> { } pub fn get_all_f(state: SharedState) -> impl Filter + Clone { - warp::path!("get_all") + warp::path!("api" / "get_all") .map(move || state.clone()) .and_then(get_all) } \ No newline at end of file