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]
fn new(tree: Tree, response_finalizer: ResponseFinalizer) -> Router
Creates a Router
instance.
Trait Implementations
impl Clone for Router
[src]
fn clone(&self) -> Router
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl NewHandler for Router
[src]
type Instance = Router
The type of Handler
created by the implementor.
fn new_handler(&self) -> Result<Self::Instance>
Create and return a new Handler
value.
impl Handler for Router
[src]
fn handle(self, state: State, req: Request) -> Box<HandlerFuture>
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
.