2 releases

0.1.1 Feb 20, 2023
0.1.0 Feb 13, 2023

#700 in HTTP server

Download history 82/week @ 2024-07-21 82/week @ 2024-07-28 149/week @ 2024-08-04 144/week @ 2024-08-11 1272/week @ 2024-08-18 4513/week @ 2024-08-25 5941/week @ 2024-09-01 7259/week @ 2024-09-08 6723/week @ 2024-09-15 7019/week @ 2024-09-22 8085/week @ 2024-09-29 9940/week @ 2024-10-06 9154/week @ 2024-10-13 9830/week @ 2024-10-20 8733/week @ 2024-10-27 4587/week @ 2024-11-03

32,706 downloads per month
Used in atomic-server

MIT license

72KB
59 lines

simple-server-timing-header

crates.io Documentation

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());
}

Example of server-timing in Chrome dev tools


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");
}

No runtime deps