add: ip test api

This commit is contained in:
trisua 2025-04-19 19:09:24 -04:00
parent 3db7f2699c
commit a78ee0f8d2
2 changed files with 21 additions and 1 deletions

View file

@ -26,6 +26,7 @@ pub fn routes() -> Router {
// misc
.route("/util/proxy", get(util::proxy_request))
.route("/util/lang", get(util::set_langfile_request))
.route("/util/ip", get(util::ip_test_request))
// reactions
.route("/reactions", post(reactions::create_request))
.route("/reactions/{id}", get(reactions::get_request))

View file

@ -1,6 +1,12 @@
use super::auth::images::read_image;
use crate::State;
use axum::{Extension, body::Body, extract::Query, http::HeaderMap, response::IntoResponse};
use axum::{
body::Body,
extract::Query,
http::{HeaderMap, HeaderValue},
response::IntoResponse,
Extension,
};
use pathbufd::PathBufD;
use serde::Deserialize;
@ -131,3 +137,16 @@ pub async fn set_langfile_request(Query(props): Query<LangFileQuery>) -> impl In
"Language changed",
)
}
pub async fn ip_test_request(
headers: HeaderMap,
Extension(data): Extension<State>,
) -> impl IntoResponse {
let data = &(data.read().await).0;
headers
.get(data.0.security.real_ip_header.to_owned())
.unwrap_or(&HeaderValue::from_static(""))
.to_str()
.unwrap_or("")
.to_string()
}