add: util ip endpoint
This commit is contained in:
parent
360e822d76
commit
a49efdd238
1 changed files with 10 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue