add: ip test api
This commit is contained in:
parent
3db7f2699c
commit
a78ee0f8d2
2 changed files with 21 additions and 1 deletions
|
@ -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))
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue