Trait RouteModule

Source
pub trait RouteModule<V> {
    // Required method
    fn apply(&self, block: &mut RouteBlock<V>);
}
Expand description

Trait implemented by types that group multiple routes together.

The trait is generic over V, the same configuration type that a Server is parameterized with. This means a RouteModule can freely access whatever user defined state is injected into each Request. Because Rust monomorphizes generic code, this additional layer of abstraction has zero runtime cost.

Implementors should populate the provided RouteBlock with their routes when RouteModule::apply is called. Routes added in this way are indistinguishable from those registered directly on the server.

Required Methods§

Source

fn apply(&self, block: &mut RouteBlock<V>)

Insert routes into the supplied RouteBlock.

This method is called by Server::module. Use the provided RouteBlock to add individual routes with RouteBlock::add.

Implementors§