Struct gotham::router::Router [] [src]

pub struct Router { /* fields omitted */ }

Responsible for dispatching Requests to a linked Route and dispatching error states when a valid Route is unable to be determined or internal error states occur.

The Router is capable of delegating Requests to secondary Router instances which allows it to support "Modular Applications". A modular application contains multiple applications within a single binary but have clear boundaries between them, via Rust module seperation. Modular applications live within a single repository. Modular applications are roughly a halfway point between monolithic application design and microservice application design. Modular Applications may share modules that are not specifically asigned to any one application e.g. Authentication/Authorization/Identity.

Please see the documentation for Route in order to create routes that delegate to secondary Routers.

Examples

  let tree_builder = TreeBuilder::new();
  let tree = tree_builder.finalize();
  let response_finalizer = ResponseFinalizerBuilder::new().finalize();

  Router::new(tree, response_finalizer);

Methods

impl Router
[src]

Creates a Router instance.

Trait Implementations

impl Clone for Router
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl NewHandler for Router
[src]

The type of Handler created by the implementor.

Create and return a new Handler value.

impl Handler for Router
[src]

Handles the Request by determining the correct Route from the internal Tree, storing any path related variables in State and dispatching to the associated Handler.