Skip to main content

RouteController

Trait RouteController 

Source
pub trait RouteController: Send + Sync {
    // Required methods
    fn base_path(&self) -> &str;
    fn register_routes<'life0, 'life1, 'async_trait>(
        &'life0 self,
        router: &'life1 mut Router,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn version(&self) -> u32 { ... }
    fn full_path(&self, path: &str) -> String { ... }
    fn register<'life0, 'life1, 'async_trait>(
        &'life0 self,
        router: &'life1 mut Router,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn type_name(&self) -> &'static str { ... }
}
Expand description

Groups related routes under a shared base path and version. Implement RouteController::base_path and RouteController::register_routes; override RouteController::version to prefix paths with /v{version}.

Required Methods§

Source

fn base_path(&self) -> &str

Base path prefix for every route registered by this controller.

Source

fn register_routes<'life0, 'life1, 'async_trait>( &'life0 self, router: &'life1 mut Router, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Registers this controller’s routes on router, typically via RouteControllerExt.

Provided Methods§

Source

fn version(&self) -> u32

API version prefix; 0 means no /v{version} segment is added.

Source

fn full_path(&self, path: &str) -> String

Resolves a relative path to its full mounted path including base path and version.

Source

fn register<'life0, 'life1, 'async_trait>( &'life0 self, router: &'life1 mut Router, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Default registration entry point; delegates to RouteController::register_routes.

Source

fn type_name(&self) -> &'static str

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§