Skip to main content

build_rest_op_resolver_with_prefix

Function build_rest_op_resolver_with_prefix 

Source
pub fn build_rest_op_resolver_with_prefix(
    prefix: &str,
    routes: &'static [RouteTransportDescriptor],
) -> impl Fn(&Request<Body>) + Send + Sync + use<>
Expand description

build_rest_op_resolver for a router mounted under prefix, e.g. build_rest_op_resolver_with_prefix("/api", ROUTE_TRANSPORTS) to match Router::nest("/api", router).

prefix is forgiving about spelling — "/api", "/api/" and "api" are the same mount — but strict about boundaries: a path that is not under the prefix at a segment boundary resolves unresolved rather than being matched on a truncated remainder. /apiary/... is not under /api.

The resolver keeps its own normalised copy of prefix and borrows nothing (use<>), so the prefix may come from runtime configuration; without it, edition 2024 captured prefix’s lifetime and a String prefix could not meet with_op_resolver’s 'static bound.