request_log

Request logging middleware.

Logs each HTTP request with method, path, status, and elapsed time.

fn log_request

source

pub async fn log_request(request: Request, next: Next) -> Response

Middleware that logs each request on completion.

The line is logged at info level as <method> <path> <status> <elapsed>, such as GET /tasks 200 12ms; the query string is not logged.

Parameter Type Description
request Request the incoming request
next Next the rest of the middleware stack and the handler
returns Response The handler’s response, unchanged.

fn format_duration

source

fn format_duration(d: Duration) -> String

Format an elapsed time for the request log: whole milliseconds under a second, else seconds.

Parameter Type Description
d Duration the elapsed time
returns String Text such as 12ms or 1.5s.