mirror of
https://github.com/JonasunderscoreJones/jonas_jones-api.git
synced 2025-10-22 16:59:17 +02:00
Added basic frame for mod update tracker
This commit is contained in:
parent
32b0c87c00
commit
6a53f1a9cb
6 changed files with 37 additions and 1 deletions
|
@ -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<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
|
||||
return get_v1_builtin_routes()
|
||||
.or(get_v1_kcomebacks_routes());
|
||||
.or(get_v1_kcomebacks_routes())
|
||||
.or(get_v1_updates_routes());
|
||||
}
|
9
src/v1/updates/minecraft/mod.rs
Normal file
9
src/v1/updates/minecraft/mod.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use warp::Filter;
|
||||
|
||||
mod mods;
|
||||
|
||||
use mods::get_mods_paths;
|
||||
|
||||
pub fn get_minecraft_paths() -> impl warp::Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
|
||||
get_mods_paths()
|
||||
}
|
17
src/v1/updates/minecraft/mods/mod.rs
Normal file
17
src/v1/updates/minecraft/mods/mod.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
use warp::{Filter, filters::addr::remote};
|
||||
|
||||
pub fn get_mods_paths() -> impl warp::Filter<Extract = impl warp::Reply, Error = warp::Rejection> + 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<std::net::SocketAddr>) -> String {
|
||||
format!("modname: {}, loadername: {}, version: {}, IP: {}", modname, loadername, version, remote_ip.unwrap_or(std::net::SocketAddr::from(([0, 0, 0, 0], 0))).ip())
|
||||
}
|
7
src/v1/updates/mod.rs
Normal file
7
src/v1/updates/mod.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
mod minecraft;
|
||||
|
||||
use minecraft::get_minecraft_paths;
|
||||
|
||||
pub fn get_updates_routes() -> impl warp::Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
|
||||
get_minecraft_paths()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue