| Crates.io | axum-server-timings |
| lib.rs | axum-server-timings |
| version | 0.2.0 |
| created_at | 2025-01-02 21:14:30.473242+00 |
| updated_at | 2025-01-02 21:14:30.473242+00 |
| description | Simplify adding the server-timings header to your Axum applications |
| homepage | |
| repository | https://github.com/randomairborne/axum-server-timings |
| max_upload_size | |
| id | 1501868 |
| size | 29,152 |
Time your axum handlers with just a method call!
ServerTimings allows you to instantiate one struct and automatically get a header
with all your timing data inserted, for use in browser devtools for performance testing.
The duration between calls to record is recorded automatically.
async fn handler() -> (ServerTimings, &'static str) {
let mut timings = ServerTimings::new();
tokio::time::sleep(Duration::from_secs_f32(0.1)).await;
timings.record("wait", "How long the sleep took");
tokio::time::sleep(Duration::from_secs_f32(0.5)).await;
timings.record("wait2", "How long the second sleep took");
(timings, "timings test")
}
RUSTFLAGS="--cfg hide_server_timings"