Added request logging middleware

This commit is contained in:
Random936
2024-12-22 20:40:04 -08:00
parent ceb1ab44d3
commit 0b2a4f130e
5 changed files with 49 additions and 20 deletions

17
src/logging.rs Normal file
View File

@@ -0,0 +1,17 @@
use std::net::SocketAddr;
use axum::{
extract::ConnectInfo,
response::Response,
middleware::Next,
http::Request,
body::Body
};
pub async fn logging_middleware(
ConnectInfo(addr): ConnectInfo<SocketAddr>,
req: Request<Body>,
next: Next
) -> Response {
println!("[{}] {} {}", addr, req.method(), req.uri());
next.run(req).await
}