mirror of
https://github.com/NetworkCats/rustyip.git
synced 2026-11-13 16:17:46 +00:00
fix: apply rustfmt and replace map_or with is_some_and per clippy
This commit is contained in:
@@ -9,7 +9,7 @@ use maxminddb::Reader;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::models::{
|
||||
from_mmdb_record, IpInfo, MmdbAsn, MmdbCity, MmdbCountry, MmdbProxy, MmdbRecord, ProxyInfo,
|
||||
IpInfo, MmdbAsn, MmdbCity, MmdbCountry, MmdbProxy, MmdbRecord, ProxyInfo, from_mmdb_record,
|
||||
};
|
||||
|
||||
pub type DbReader = Reader<Vec<u8>>;
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ fn proxy_field_handler(
|
||||
return Err(AppError::DbNotReady);
|
||||
}
|
||||
let ip = resolve_ip(headers, query, state.dev_mode)?;
|
||||
let value = db::lookup_proxy(&state.db, ip).map_or(false, |p| field(&p));
|
||||
let value = db::lookup_proxy(&state.db, ip).is_some_and(|p| field(&p));
|
||||
Ok(format!("{value}\n"))
|
||||
}
|
||||
|
||||
|
||||
+2
-5
@@ -23,9 +23,7 @@ pub use api::{
|
||||
vpn_handler,
|
||||
};
|
||||
pub use html::{not_found, root, root_redirect, root_trailing_slash};
|
||||
pub use seo::{
|
||||
build_openapi_json, favicon, manifest, openapi_json, robots_txt, sitemap_xml,
|
||||
};
|
||||
pub use seo::{build_openapi_json, favicon, manifest, openapi_json, robots_txt, sitemap_xml};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct IpQuery {
|
||||
@@ -107,8 +105,7 @@ fn handle_non_browser_request(
|
||||
|
||||
if wants_json(headers) && query.ip.is_none() {
|
||||
return Some(
|
||||
match extract_client_ip(headers, state.dev_mode)
|
||||
.and_then(|ip| lookup_ip(&state.db, ip))
|
||||
match extract_client_ip(headers, state.dev_mode).and_then(|ip| lookup_ip(&state.db, ip))
|
||||
{
|
||||
Ok(info) => axum::Json(info).into_response(),
|
||||
Err(e) => e.into_response(),
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@ pub async fn openapi_json(State(state): State<AppState>) -> Response {
|
||||
}
|
||||
|
||||
pub fn build_openapi_json(site_domain: &str) -> Arc<str> {
|
||||
let mut spec: serde_json::Value =
|
||||
serde_json::from_str(include_str!("../../openapi.json")).expect("openapi.json must be valid");
|
||||
let mut spec: serde_json::Value = serde_json::from_str(include_str!("../../openapi.json"))
|
||||
.expect("openapi.json must be valid");
|
||||
|
||||
let server_url = format!("https://{site_domain}");
|
||||
spec["servers"] = serde_json::json!([{ "url": server_url }]);
|
||||
|
||||
Reference in New Issue
Block a user