add: util ip endpoint

This commit is contained in:
trisua 2025-07-25 19:45:05 -04:00
parent 360e822d76
commit a49efdd238

View file

@ -43,6 +43,7 @@ pub fn routes() -> Router {
.route("/{slug}", get(view_request))
.route("/{slug}/edit", get(editor_request))
// api
.route("/api/v1/util/ip", get(util_ip))
.route("/api/v1/render", post(render_request))
.route("/api/v1/entries", post(create_request))
.route("/api/v1/entries/{slug}", post(edit_request))
@ -286,6 +287,15 @@ async fn exists_request(
})
}
async fn util_ip(headers: HeaderMap) -> impl IntoResponse {
headers
.get(var("REAL_IP_HEADER").unwrap_or("CF-Connecting-IP".to_string()))
.unwrap_or(&HeaderValue::from_static(""))
.to_str()
.unwrap_or("")
.to_string()
}
#[derive(Deserialize)]
struct CreateEntry {
content: String,