Replace Rusqlite by Sqlx and Actix by Axum (A lot of changes)
This commit is contained in:
parent
57d7e7a3ce
commit
980c5884a4
28 changed files with 2860 additions and 2262 deletions
|
|
@ -1,11 +1,20 @@
|
|||
use log::error;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
pub fn unwrap_print_err<T, E>(r: Result<T, E>) -> T
|
||||
where
|
||||
E: std::fmt::Debug,
|
||||
{
|
||||
if let Err(ref error) = r {
|
||||
error!("{:?}", error);
|
||||
}
|
||||
r.unwrap()
|
||||
use axum::http::HeaderMap;
|
||||
|
||||
use crate::consts;
|
||||
|
||||
pub fn get_ip_and_user_agent(headers: &HeaderMap, remote_address: SocketAddr) -> (String, String) {
|
||||
let ip = match headers.get(consts::REVERSE_PROXY_IP_HTTP_FIELD) {
|
||||
Some(v) => v.to_str().unwrap_or_default().to_string(),
|
||||
None => remote_address.to_string(),
|
||||
};
|
||||
|
||||
let user_agent = headers
|
||||
.get(axum::http::header::USER_AGENT)
|
||||
.map(|v| v.to_str().unwrap_or_default())
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
|
||||
(ip, user_agent)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue