From 655d04f8dfa73ba43efb030b68f3350e75b00589 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Sat, 20 Jan 2024 19:31:54 -0800 Subject: [PATCH] Move proxy to make it an example, update its README.md --- Cargo.toml | 1 - README.md | 2 +- riven/Cargo.toml | 5 ++++- {example => riven/examples}/proxy/README.md | 6 +++--- {example/proxy/src => riven/examples/proxy}/main.rs | 0 5 files changed, 8 insertions(+), 6 deletions(-) rename {example => riven/examples}/proxy/README.md (93%) rename {example/proxy/src => riven/examples/proxy}/main.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index c966837..232794b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,4 @@ [workspace] members = [ "riven", - "example/proxy", ] diff --git a/README.md b/README.md index 8826554..f22d3ad 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Output: ``` The [`RiotApi` struct documentation](https://docs.rs/riven/latest/riven/struct.RiotApi.html) contains additional usage information. The [tests](https://github.com/MingweiSamuel/Riven/tree/v/2.x.x/riven/tests) -and [example proxy](https://github.com/MingweiSamuel/Riven/tree/v/2.x.x/example/proxy) +and [example proxy](https://github.com/MingweiSamuel/Riven/tree/v/2.x.x/riven/examples/proxy) provide more example usage. ## Feature Flags diff --git a/riven/Cargo.toml b/riven/Cargo.toml index a6ce121..58d0ad6 100644 --- a/riven/Cargo.toml +++ b/riven/Cargo.toml @@ -58,4 +58,7 @@ colored = "2" env_logger = "0.10.0" fake_instant = "0.5.0" futures = "0.3" -tokio = { version = "1", default-features = false, features = [ "rt-multi-thread" ] } +hyper = { version = "0.14", features = [ "server" ] } +tokio = { version = "1", features = [ "full" ] } +tracing = "0.1" +tracing-subscriber = "0.2" diff --git a/example/proxy/README.md b/riven/examples/proxy/README.md similarity index 93% rename from example/proxy/README.md rename to riven/examples/proxy/README.md index 3df8f46..aab2745 100644 --- a/example/proxy/README.md +++ b/riven/examples/proxy/README.md @@ -14,7 +14,7 @@ when Riven is at the rate limit. Set `RGAPI_KEY` env var then run: ```bash export RGAPI_KEY=RGAPI-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX -cargo run +cargo run --example proxy ``` Test in your browser or using `curl`. The first path segment specifies the region: @@ -25,8 +25,8 @@ $ curl http://localhost:3000/na1/lol/summoner/v4/summoners/by-name/LugnutsK $ curl http://localhost:3000/eu/val/status/v1/platform-data {"id": "EU", "name": "Europe", "locales": ["..."], "maintenances": [], "incidents": []} -$ curl http://localhost:3000/americas/lol/tournament-stub/v4/providers -H "Content-Type: application/json" -d '{"region":"JP","url":"https://github.com/MingweiSamuel/Riven"}' -764 +$ curl http://localhost:3000/americas/lol/tournament-stub/v5/providers -H "Content-Type: application/json" -d '{"region":"JP","url":"https://github.com/MingweiSamuel/Riven"}' +1 $ curl http://localhost:3000/na1/unknown/endpoint {"error":"Riot API endpoint method not found."} diff --git a/example/proxy/src/main.rs b/riven/examples/proxy/main.rs similarity index 100% rename from example/proxy/src/main.rs rename to riven/examples/proxy/main.rs