Skip to main content

Module path

Module path 

Source
Expand description

URI path handling shared by every REST service.

Smithy @httpLabel semantics: the client percent-encodes each label value, so a / inside a non-greedy label travels as %2F and : in an ARN usually travels as %3A. The server must therefore split the raw path on / FIRST and percent-decode each segment afterwards; decoding before splitting would turn an encoded / into a segment boundary. A greedy label ({Key+}) is the decoded segments re-joined with /.

Dispatch builds crate::service::AwsRequest::path_segments with split_path_segments, so handlers receive decoded labels and must not decode them again (a label of %2525 is the literal %25, not %). Routers that need the undecoded wire path read raw_path instead.

Functions§

percent_decode_segment
Percent-decode one URI path segment per RFC 3986. + is a literal + in a path (only application/x-www-form-urlencoded data maps it to a space). A malformed escape (%zz, a trailing %) is kept verbatim, and bytes that do not form valid UTF-8 are replaced lossily – decoding never fails and never panics.
split_path_segments
Split a raw URI path into decoded segments: split on /, drop empty segments (leading, trailing and doubled slashes), then percent-decode each segment exactly once.
split_raw_path_segments
Split a raw URI path into its undecoded segments, dropping empty ones. This is the wire form of split_path_segments for handlers that must forward or match the path exactly as the client sent it (API Gateway execute-api data plane, for one).