Skip to content

Overview

The path is a component of the request target.
E.g. /foo/bar is the path component in https://example.com/foo/bar?baz=qux or /foo/bar?baz=qux.

The path is primarily used for routing requests to the right handlers.
The path can also be used to encode dynamic data—check out "Path parameters" for more details.

Injection

Inject RequestHead to access the raw path via its target field:

src/path/routes.rs
use pavex::http::StatusCode;
use pavex::request::RequestHead;

pub fn handler(head: &RequestHead) -> StatusCode {
    println!("The raw path is: {}", head.target.path());
    StatusCode::OK
}