Added request logging middleware
This commit is contained in:
17
src/logging.rs
Normal file
17
src/logging.rs
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user