diff --git a/src/v1/minecraft/mod.rs b/src/v1/minecraft/mod.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/v1/minecraft/mods/mod.rs b/src/v1/minecraft/mods/mod.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/v1/mod.rs b/src/v1/mod.rs index 7c33f3e..f4d4263 100644 --- a/src/v1/mod.rs +++ b/src/v1/mod.rs @@ -1,12 +1,15 @@ mod builtin; mod kcomebacks; +mod updates; pub use builtin::get_builtin_routes as get_v1_builtin_routes; pub use kcomebacks::get_kcomebacks_routes as get_v1_kcomebacks_routes; +pub use updates::get_updates_routes as get_v1_updates_routes; use warp::Filter; pub fn get_v1_routes() -> impl warp::Filter + Clone { return get_v1_builtin_routes() - .or(get_v1_kcomebacks_routes()); + .or(get_v1_kcomebacks_routes()) + .or(get_v1_updates_routes()); } \ No newline at end of file diff --git a/src/v1/updates/minecraft/mod.rs b/src/v1/updates/minecraft/mod.rs new file mode 100644 index 0000000..153f795 --- /dev/null +++ b/src/v1/updates/minecraft/mod.rs @@ -0,0 +1,9 @@ +use warp::Filter; + +mod mods; + +use mods::get_mods_paths; + +pub fn get_minecraft_paths() -> impl warp::Filter + Clone { + get_mods_paths() +} \ No newline at end of file diff --git a/src/v1/updates/minecraft/mods/mod.rs b/src/v1/updates/minecraft/mods/mod.rs new file mode 100644 index 0000000..c12631f --- /dev/null +++ b/src/v1/updates/minecraft/mods/mod.rs @@ -0,0 +1,17 @@ +use warp::{Filter, filters::addr::remote}; + +pub fn get_mods_paths() -> impl warp::Filter + Clone { + // any path that starts with /v1/updates/minecraft/mods/{modname}/{loadername}/{version} calls handle_path + warp::path("v1").and(warp::path("updates")).and(warp::path("minecraft")).and(warp::path("mods")) + + .and(warp::path::param()) + .and(warp::path::param()) + .and(warp::path::param()) + .and(warp::path::end()) + .and(warp::addr::remote()) + .map(handle_path) +} + +fn handle_path(modname: String, loadername: String, version: String, remote_ip: Option) -> String { + format!("modname: {}, loadername: {}, version: {}, IP: {}", modname, loadername, version, remote_ip.unwrap_or(std::net::SocketAddr::from(([0, 0, 0, 0], 0))).ip()) +} \ No newline at end of file diff --git a/src/v1/updates/mod.rs b/src/v1/updates/mod.rs new file mode 100644 index 0000000..e1be452 --- /dev/null +++ b/src/v1/updates/mod.rs @@ -0,0 +1,7 @@ +mod minecraft; + +use minecraft::get_minecraft_paths; + +pub fn get_updates_routes() -> impl warp::Filter + Clone { + get_minecraft_paths() +} \ No newline at end of file