feat: add request logging middleware for all API calls

- Added request_logger middleware in middleware.rs
- Logs every API request with method, path, and query string
- Logs every API response with status code and duration
- Skips health checks and static files to reduce noise
- Error responses (4xx/5xx) logged at warn/error level
- Added to server router as global middleware
This commit is contained in:
Accusys
2026-08-06 09:50:20 +08:00
parent 23c6f63742
commit 64f5e3f543
2 changed files with 44 additions and 0 deletions
+1
View File
@@ -163,6 +163,7 @@ pub async fn start_server(host: &str, port: u16) -> anyhow::Result<()> {
.merge(docs::doc_routes())
.merge(protected_routes)
.layer(cors)
.layer(axum::middleware::from_fn(super::middleware::request_logger))
.with_state(state);
let addr: std::net::SocketAddr = format!("{}:{}", host, port).parse().unwrap();