Added landing visit log line
Build and Publish / Build and Publish Docker Image (push) Successful in 1m20s
Build and Publish / Build and Publish Docker Image (push) Successful in 1m20s
This commit is contained in:
@@ -16,3 +16,4 @@ multer = "3"
|
||||
futures = "0.3"
|
||||
tokio = { version = "1", features = ["fs"] }
|
||||
uuid = { version = "1", features = ["v4"] }
|
||||
tracing = "0.1"
|
||||
|
||||
@@ -6,6 +6,7 @@ use cot::request::extractors::Path;
|
||||
use cot::response::{IntoResponse, Redirect, Response};
|
||||
use cot::router::{Route, Router};
|
||||
use serde::Deserialize;
|
||||
use tracing::info;
|
||||
|
||||
use cot::db::query;
|
||||
|
||||
@@ -86,6 +87,33 @@ struct ThankYouTemplate<'a> {
|
||||
|
||||
async fn landing_page(request: Request, db: Database) -> cot::Result<Response> {
|
||||
let lang = detect_lang(&request);
|
||||
|
||||
let ua = request
|
||||
.headers()
|
||||
.get("user-agent")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("-");
|
||||
let referer = request
|
||||
.headers()
|
||||
.get("referer")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("-");
|
||||
let ip = request
|
||||
.headers()
|
||||
.get("x-forwarded-for")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.and_then(|s| s.split(',').next())
|
||||
.map(|s| s.trim())
|
||||
.unwrap_or("-");
|
||||
|
||||
info!(
|
||||
target: "landing",
|
||||
ip = ip,
|
||||
lang = lang.code(),
|
||||
referer = referer,
|
||||
ua = ua,
|
||||
"landing visit"
|
||||
);
|
||||
let key = "contact_info".to_string();
|
||||
let contact_info = query!(Setting, $key == key)
|
||||
.get(&db)
|
||||
|
||||
Reference in New Issue
Block a user