From 7e0602be237f84a434cfd1c1426eac86dc5f867e Mon Sep 17 00:00:00 2001 From: blek Date: Sat, 7 Oct 2023 23:50:48 +1000 Subject: [PATCH] just hardcode the damn paths --- filed/src/web/api.rs | 19 ++++++++++++++----- filed/src/web/api/get_all.rs | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) 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