aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/index.rst1
-rw-r--r--src/lib.rs9
2 files changed, 9 insertions, 1 deletions
diff --git a/src/index.rst b/src/index.rst
index c9c00b0..2de518c 100644
--- a/src/index.rst
+++ b/src/index.rst
@@ -18,6 +18,7 @@ For example; if a route is notated as "/v2/route/:parameter", you can access tha
- /languages: A list of all languages that appear in the https://github.com/cat-milk/Anime-Girls-Holding-Programming-Books repository
- /language/:language: A list of all images that are labeled under the language, ":language", in the https://github.com/cat-milk/Anime-Girls-Holding-Programming-Books repository
- /random: A random image from the https://github.com/cat-milk/Anime-Girls-Holding-Programming-Books repository
+ - /me: For future implementation. At the moment; only contains the caller's IP.
Notes
-----
diff --git a/src/lib.rs b/src/lib.rs
index 6f86f33..2287e89 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -35,6 +35,7 @@ mod routes;
mod structures;
mod utils;
+use serde_json::json;
use worker::Response;
/// # Errors
@@ -63,12 +64,18 @@ pub async fn main(
})
.get_async("/v2/random", |_, _| async move { routes::random().await })
.get("/v2/version", |_, _| {
- Response::from_json(&serde_json::json!({
+ Response::from_json(&json!({
"crate_version": env!("CARGO_PKG_VERSION"),
"git_commit_hash": env!("VERGEN_GIT_SHA"),
}))?
.with_cors(&utils::cors())
})
+ .get("/v2/me", |req, _| {
+ Response::from_json(&json!({
+ "ip": req.clone().unwrap().headers().get("CF-Connecting-IP").unwrap().unwrap(),
+ }))?
+ .with_cors(&utils::cors())
+ })
.run(request, environment)
.await
}