axum-server-timing

Crates.ioaxum-server-timing
lib.rsaxum-server-timing
version1.0.1
sourcesrc
created_at2023-04-19 17:50:57.174108
updated_at2024-08-19 08:54:44.351275
descriptionAn axum layer to inject the Server-Timing HTTP header into the response.
homepage
repositoryhttps://github.com/JensWalter/axum-server-timing/
max_upload_size
id843778
size62,065
Jens Walter (JensWalter)

documentation

https://docs.rs/axum-server-timing/

README

axum-server-timing

Latest Version

An axum layer to inject the Server-Timing HTTP header into the response.

For a reference on the header please see developer.mozilla.org.

Examples

Using the layer to inject the Server-Timing Header.

    let app = Router::new()
        .route("/", get(handler))
        .layer(axum_server_timing::ServerTimingLayer::new("HelloService"));

Output

HTTP/1.1 200 OK
content-type: text/html; charset=utf-8
content-length: 22
server-timing: HelloService;dur=102
date: Wed, 19 Apr 2023 15:25:40 GMT

<h1>Hello, World!</h1>

Using the layer to inject the Server-Timing Header with description.

    let app = Router::new()
        .route("/", get(handler))
        .layer(
        axum_server_timing::ServerTimingLayer::new("HelloService")
            .with_description("whatever")
        );

Output

HTTP/1.1 200 OK
content-type: text/html; charset=utf-8
content-length: 22
server-timing: HelloService;desc="whatever";dur=102
date: Wed, 19 Apr 2023 15:25:40 GMT

<h1>Hello, World!</h1>
Commit count: 14

cargo fmt