[][src]Struct gotham::router::builder::AssociatedRouteBuilder

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, 
{ /* fields omitted */ }

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

Implementations

impl<'a, C, P, PE, QSE> AssociatedRouteBuilder<'a, AnyRouteMatcher, C, P, PE, QSE> where
    C: PipelineHandleChain<P> + Copy + Send + Sync + 'static,
    P: RefUnwindSafe + Send + Sync + 'static,
    PE: PathExtractor<Body> + Send + Sync + 'static,
    QSE: QueryStringExtractor<Body> + Send + Sync + 'static, 
[src]

pub fn new(
    node_builder: &'a mut Node,
    pipeline_chain: C,
    pipelines: PipelineSet<P>
) -> Self
[src]

Create an instance of AssociatedRouteBuilder

impl<'a, M, C, P, PE, QSE> 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, 
[src]

pub fn add_route_matcher<'b, NM>(
    &'b mut self,
    matcher: NM
) -> AssociatedRouteBuilder<'b, AndRouteMatcher<M, NM>, C, P, PE, QSE> where
    NM: RouteMatcher + Send + Sync + 'static, 
[src]

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);
    });
})

pub fn with_path_extractor<'b, NPE>(
    &'b mut self
) -> AssociatedRouteBuilder<'b, M, C, P, NPE, QSE> where
    NPE: PathExtractor<Body> + Send + Sync + 'static, 
[src]

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);
    });
})

pub fn with_query_string_extractor<'b, NQSE>(
    &'b mut self
) -> AssociatedRouteBuilder<'b, M, C, P, PE, NQSE> where
    NQSE: QueryStringExtractor<Body> + Send + Sync + 'static, 
[src]

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);
    });
})

pub fn request<'b>(
    &'b mut self,
    methods: Vec<Method>
) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>
[src]

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);
    });
})

pub fn head<'b>(
    &'b mut self
) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>
[src]

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);
    });
})

pub fn get_or_head<'b>(
    &'b mut self
) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>
[src]

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);
    });
})

pub fn get<'b>(
    &'b mut self
) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>
[src]

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);
    });
})

pub fn post<'b>(
    &'b mut self
) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>
[src]

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);
    });
})

pub fn put<'b>(
    &'b mut self
) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>
[src]

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);
    });
})

pub fn patch<'b>(
    &'b mut self
) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>
[src]

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);
    });
})

pub fn delete<'b>(
    &'b mut self
) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>
[src]

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);
    });
})

pub fn options<'b>(
    &'b mut self
) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>
[src]

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

impl<'a, M, C, P, PE, QSE> RefUnwindSafe for AssociatedRouteBuilder<'a, M, C, P, PE, QSE>

impl<'a, M, C, P, PE, QSE> Send for AssociatedRouteBuilder<'a, M, C, P, PE, QSE>

impl<'a, M, C, P, PE, QSE> Sync for AssociatedRouteBuilder<'a, M, C, P, PE, QSE>

impl<'a, M, C, P, PE, QSE> Unpin for AssociatedRouteBuilder<'a, M, C, P, PE, QSE> where
    C: Unpin,
    M: Unpin,
    PE: Unpin,
    QSE: Unpin

impl<'a, M, C, P, PE, QSE> !UnwindSafe for AssociatedRouteBuilder<'a, M, C, P, PE, QSE>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,