rustio-admin 0.21.0

Django Admin, but for Rust. A small, focused admin framework.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::error::Result;
use crate::http::{Request, Response};
use crate::router::Next;

// public:
pub async fn logger(req: Request, next: Next) -> Result<Response> {
    let method = req.method().clone();
    let path = req.path().to_string();
    let start = std::time::Instant::now();
    let resp = next.run(req).await;
    let elapsed = start.elapsed();
    match &resp {
        Ok(r) => log::info!("{method} {path} -> {} ({elapsed:?})", r.status),
        Err(e) => log::warn!("{method} {path} -> error: {e}"),
    }
    resp
}