2 releases
0.1.1 | Feb 20, 2023 |
---|---|
0.1.0 | Feb 13, 2023 |
#700 in HTTP server
32,706 downloads per month
Used in atomic-server
72KB
59 lines
simple-server-timing-header
Lightweight zero-dependency Rust crate that adds a Server-Timing
header to the response of a request.
use simple_server_timing_header::Timer;
fn handle_request() {
let mut timer = Timer::new();
// ... do some stuff
timer.add("parse_headers");
// ... do some more stuff
timer.add("get_db_data");
// Sets the `Server-Timing: parse_headers;dur=0.1, get_db_data;dur=0.2` header
add_header(timer.header_key(), timer.header_value());
}
lib.rs
:
Monitor back-end performance using Server-Timing the HTTP header.
use simple_server_timing_header::Timer;
fn handle_request() {
let mut timer = Timer::new();
// ... do some stuff
timer.add("parse_headers");
// ... do some more stuff
timer.add("get_db_data");
// Generate the header value
assert_eq!(timer.header_value(), "parse_headers;dur=0, get_db_data;dur=0");
}