Trait gotham::router::route::Route[][src]

pub trait Route: RefUnwindSafe {
    type ResBody;
    fn is_match(&self, state: &State) -> Result<(), RouteNonMatch>;
fn delegation(&self) -> Delegation;
fn extract_request_path<'a>(
        &self,
        state: &mut State,
        params: SegmentMapping<'a>
    ) -> Result<(), ExtractorFailed>;
fn extend_response_on_path_error(
        &self,
        state: &mut State,
        res: &mut Response<Self::ResBody>
    );
fn extract_query_string(
        &self,
        state: &mut State
    ) -> Result<(), ExtractorFailed>;
fn extend_response_on_query_string_error(
        &self,
        state: &mut State,
        res: &mut Response<Self::ResBody>
    );
fn dispatch(&self, state: State) -> Pin<Box<HandlerFuture>>; }
Expand description

Values of the Route type are used by the Router to conditionally dispatch a request after matching the path segments successfully. The steps taken in dispatching to a Route are:

  1. Given a list of routes that match the request path, determine the first Route which indicates a match via Route::is_match;
  2. Determine whether the route’s Delegation is Internal or External. If External, halt processing and dispatch to the inner Router;
  3. Run PathExtractor and QueryStringExtractor logic to popuate State with the necessary request data. If either of these extractors fail, the request is halted here;
  4. Dispatch the request via Route::dispatch.

Route exists as a trait to allow abstraction over the generic types in RouteImpl. This trait should not be implemented outside of Gotham.

Associated Types

The type of the response body. The requirements of Hyper are that this implements HttpBody. Almost always, it will want to be hyper::Body.

Required methods

Determines if this Route should be invoked, based on the request data in `State.

Determines if this Route intends to delegate requests to a secondary Router instance.

Extracts dynamic components of the Request path and stores the PathExtractor in State.

Extends the Response object when the PathExtractor fails.

Extracts the query string parameters and stores the QueryStringExtractor in State.

Extends the Response object when query string extraction fails.

Dispatches the request to this Route, which will execute the pipelines and the handler assigned to the `Route.

Implementors