pub struct AssociatedRouteBuilder<'a, M, C, P, PE, QSE>where
    M: RouteMatcher + Send + Sync + 'static,
    C: PipelineHandleChain<P> + Copy + Send + Sync + 'static,
    P: RefUnwindSafe + Send + Sync + 'static,
    PE: PathExtractor<Body> + Send + Sync + 'static,
    QSE: QueryStringExtractor<Body> + Send + Sync + 'static,
{ /* private fields */ }
Expand description

Implements the methods required for associating a number of routes with a single path. This is used by DrawRoutes::associated.

Implementations

Create an instance of AssociatedRouteBuilder

Adds aadditional RouteMatcher requirements to all subsequently associated routes.

Examples
build_simple_router(|route| {
    let matcher = AcceptHeaderRouteMatcher::new(vec![mime::APPLICATION_JSON]);

    route.associate("/resource/path", |assoc| {
        let mut assoc = assoc.add_route_matcher(matcher);

        assoc.get().to(my_handler);
    });
})

Binds a new PathExtractor to the associated routes.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

#[derive(Deserialize, StateData, StaticResponseExtender)]
struct MyPathExtractor {
    id: u32,
}

build_simple_router(|route| {
    route.associate("/resource/:id", |assoc| {
        let mut assoc = assoc.with_path_extractor::<MyPathExtractor>();
        assoc.get().to(handler);
    });
})

Binds a new QueryStringExtractor to the associated routes.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

#[derive(StateData, Deserialize, StaticResponseExtender)]
struct MyQueryStringExtractor {
    val: String,
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        let mut assoc = assoc.with_query_string_extractor::<MyQueryStringExtractor>();
        assoc.get().to(handler);
    });
})

Associates a route which matches requests with any of the specified methods, to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.request(vec![Method::GET, Method::HEAD, Method::POST]).to(handler);
    });
})

Associates a route which matches HEAD requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.head().to(handler);
    });
})

Associates a route which matches GET or HEAD requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.get_or_head().to(handler);
    });
})

Associates a route which matches GET requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.get().to(handler);
    });
})

Associates a route which matches POST requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.post().to(handler);
    });
})

Associates a route which matches PUT requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.put().to(handler);
    });
})

Associates a route which matches PATCH requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.patch().to(handler);
    });
})

Associates a route which matches DELETE requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.delete().to(handler);
    });
})

Associates a route which matches OPTIONS requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.options().to(handler);
    });
})

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more