Struct gotham::router::non_match::RouteNonMatch [] [src]

pub struct RouteNonMatch { /* fields omitted */ }

The error type used for a non-matching route, as returned by RouteMatcher::is_match. Multiple values of this type can be combined by matchers that are wrapping other matchers, using the intersection / union methods. The data within is used by the Router to create a Response when no routes were successfully matched.

struct MyRouteMatcher;

impl RouteMatcher for MyRouteMatcher {
    fn is_match(&self, state: &State) -> Result<(), RouteNonMatch> {
        match state.borrow::<Method>() {
            &Method::Get => Ok(()),
            _ => Err(
                RouteNonMatch::new(StatusCode::MethodNotAllowed)
                    .with_allow_list(&[Method::Get]),
            ),
        }
    }
}

Methods

impl RouteNonMatch
[src]

[src]

Creates a new RouteNonMatch value with the given HTTP status.

[src]

Adds an allow list to a RouteNonMatch. Typically this is used with a 405 Method Not Allowed status code, so the Router can accurately populate the Allow header in the response. It must be populated by any RouteMatcher which restricts the HTTP method.

[src]

Takes the intersection of two RouteNonMatch values, producing a single result. This is intended for use in cases where two RouteMatcher instances with a logical AND connection have both indicated a non-match, and their results need to be aggregated.

This is typically for Gotham internal use, but may be useful for implementors of matchers which wrap other RouteMatcher instances. See the AndRouteMatcher implementation (in gotham::router::route::matcher::and) for an example.

[src]

Takes the union of two RouteNonMatch values, producing a single result. This is intended for use in cases where two RouteMatcher instances with a logical OR connection have both indicated a non-match, and their results need to be aggregated.

This is typically for Gotham internal use, but may be useful for implementors of matchers which wrap other RouteMatcher instances. See the Node::select_route implementation (in gotham::router::tree) for an example.

Trait Implementations

impl From<RouteNonMatch> for StatusCode
[src]

[src]

Performs the conversion.

Auto Trait Implementations

impl Send for RouteNonMatch

impl Sync for RouteNonMatch