Struct gotham::router::builder::RouterBuilder

source ·
pub struct RouterBuilder<'a, C, P>
where C: PipelineHandleChain<P> + Copy + Send + Sync + 'static, P: Send + Sync + 'static,
{ /* private fields */ }
Expand description

The top-level builder which is created by build_router and passed to the provided closure. See the build_router function and the DrawRoutes trait for usage.

Implementations§

source§

impl<'a, C, P> RouterBuilder<'a, C, P>
where C: PipelineHandleChain<P> + Copy + Send + Sync + 'static, P: Send + Sync + 'static,

source

pub fn add_response_extender<E>(&mut self, status_code: StatusCode, extender: E)
where E: ResponseExtender<Body> + Send + Sync + 'static,

Adds a ResponseExtender to the ResponseFinalizer in the Router.

struct MyExtender;

impl ResponseExtender<Body> for MyExtender {
    fn extend(&self, state: &mut State, response: &mut Response<Body>) {
        // Extender implementation omitted.
    }
}

fn router() -> Router {
    build_simple_router(|route| {
        route.add_response_extender(StatusCode::INTERNAL_SERVER_ERROR, MyExtender);
    })
}

Trait Implementations§

source§

impl<'a, C, P> DrawRoutes<C, P> for RouterBuilder<'a, C, P>
where C: PipelineHandleChain<P> + Copy + Send + Sync + 'static, P: RefUnwindSafe + Send + Sync + 'static,

source§

fn get_or_head<'b>( &'b mut self, path: &str ) -> SingleRouteBuilder<'b, MethodOnlyRouteMatcher, C, P, NoopPathExtractor, NoopQueryStringExtractor>

Creates a route which matches GET and HEAD requests to the given path. Read more
source§

fn get<'b>( &'b mut self, path: &str ) -> SingleRouteBuilder<'b, MethodOnlyRouteMatcher, C, P, NoopPathExtractor, NoopQueryStringExtractor>

Creates a route which matches only GET requests to the given path (ignoring HEAD requests). Read more
source§

fn head<'b>( &'b mut self, path: &str ) -> SingleRouteBuilder<'b, MethodOnlyRouteMatcher, C, P, NoopPathExtractor, NoopQueryStringExtractor>

Creates a route which matches HEAD requests to the given path. Read more
source§

fn post<'b>( &'b mut self, path: &str ) -> SingleRouteBuilder<'b, MethodOnlyRouteMatcher, C, P, NoopPathExtractor, NoopQueryStringExtractor>

Creates a route which matches POST requests to the given path. Read more
source§

fn put<'b>( &'b mut self, path: &str ) -> SingleRouteBuilder<'b, MethodOnlyRouteMatcher, C, P, NoopPathExtractor, NoopQueryStringExtractor>

Creates a route which matches PUT requests to the given path. Read more
source§

fn patch<'b>( &'b mut self, path: &str ) -> SingleRouteBuilder<'b, MethodOnlyRouteMatcher, C, P, NoopPathExtractor, NoopQueryStringExtractor>

Creates a route which matches PATCH requests to the given path. Read more
source§

fn delete<'b>( &'b mut self, path: &str ) -> SingleRouteBuilder<'b, MethodOnlyRouteMatcher, C, P, NoopPathExtractor, NoopQueryStringExtractor>

Creates a route which matches DELETE requests to the given path. Read more
source§

fn options<'b>( &'b mut self, path: &str ) -> SingleRouteBuilder<'b, MethodOnlyRouteMatcher, C, P, NoopPathExtractor, NoopQueryStringExtractor>

Creates a route which matches OPTIONS requests to the given path. Read more
source§

fn request<'b, IRM, M>( &'b mut self, matcher: IRM, path: &str ) -> SingleRouteBuilder<'b, M, C, P, NoopPathExtractor, NoopQueryStringExtractor>
where IRM: IntoRouteMatcher<Output = M>, M: RouteMatcher + Send + Sync + 'static,

Creates a single route which matches any requests to the given path with one of the given methods. The path can consist of static or dynamic segments, for example: Read more
source§

fn scope<F>(&mut self, path: &str, f: F)
where F: FnOnce(&mut ScopeBuilder<'_, C, P>),

Begins defining a new scope, based on a given path prefix. Read more
source§

fn with_pipeline_chain<F, NC>(&mut self, pipeline_chain: NC, f: F)
where F: FnOnce(&mut ScopeBuilder<'_, NC, P>), NC: PipelineHandleChain<P> + Copy + Send + Sync + 'static,

Begins a new scope at the current location, with an alternate pipeline chain. Read more
source§

fn delegate<'b>( &'b mut self, path: &str ) -> DelegateRouteBuilder<'b, AnyRouteMatcher, C, P>

Begins delegating a subpath of the tree. Read more
source§

fn delegate_without_pipelines<'b>( &'b mut self, path: &str ) -> DelegateRouteBuilder<'b, AnyRouteMatcher, (), P>

Begins delegating a subpath of the tree, but does not dispatch the requests via this router’s PipelineChain. Read more
source§

fn associate<'b, F>(&'b mut self, path: &str, f: F)

Begins associating routes with a fixed path in the tree. In this way, multiple routes can be quickly associated with a single location. Read more

Auto Trait Implementations§

§

impl<'a, C, P> Freeze for RouterBuilder<'a, C, P>
where C: Freeze,

§

impl<'a, C, P> RefUnwindSafe for RouterBuilder<'a, C, P>
where P: RefUnwindSafe,

§

impl<'a, C, P> Send for RouterBuilder<'a, C, P>

§

impl<'a, C, P> Sync for RouterBuilder<'a, C, P>

§

impl<'a, C, P> Unpin for RouterBuilder<'a, C, P>
where C: Unpin,

§

impl<'a, C, P> !UnwindSafe for RouterBuilder<'a, C, P>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more