18 lines
369 B
Rust
18 lines
369 B
Rust
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
|
|
}
|