#axum-server #http-header #inject #layer #server-timing #response

axum-server-timing

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

4 releases (2 breaking)

0.3.1 Mar 25, 2024
0.3.0 Dec 1, 2023
0.2.0 May 22, 2023
0.1.0 Apr 19, 2023

#263 in HTTP server

Download history 38/week @ 2023-12-25 133/week @ 2024-01-01 48/week @ 2024-01-08 19/week @ 2024-01-15 95/week @ 2024-01-22 90/week @ 2024-01-29 58/week @ 2024-02-05 198/week @ 2024-02-12 71/week @ 2024-02-19 83/week @ 2024-02-26 114/week @ 2024-03-04 214/week @ 2024-03-11 170/week @ 2024-03-18 322/week @ 2024-03-25 87/week @ 2024-04-01

601 downloads per month

MIT/Apache

18KB
195 lines

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>

Dependencies

~5–7MB
~127K SLoC