ElifController

Trait ElifController 

Source
pub trait ElifController:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &str;
    fn base_path(&self) -> &str;
    fn routes(&self) -> Vec<ControllerRoute>;
    fn handle_request<'async_trait>(
        self: Arc<Self>,
        method_name: String,
        request: ElifRequest,
    ) -> Pin<Box<dyn Future<Output = HttpResult<ElifResponse>> + Send + 'async_trait>>
       where Self: 'async_trait;

    // Provided methods
    fn dependencies(&self) -> Vec<String> { ... }
    fn handle_request_dyn<'life0, 'async_trait>(
        &'life0 self,
        method_name: String,
        request: ElifRequest,
    ) -> Pin<Box<dyn Future<Output = HttpResult<ElifResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Main trait for controllers with automatic route registration

Required Methods§

Source

fn name(&self) -> &str

Controller name for identification

Source

fn base_path(&self) -> &str

Base path for all routes in this controller

Source

fn routes(&self) -> Vec<ControllerRoute>

Route definitions for this controller

Source

fn handle_request<'async_trait>( self: Arc<Self>, method_name: String, request: ElifRequest, ) -> Pin<Box<dyn Future<Output = HttpResult<ElifResponse>> + Send + 'async_trait>>
where Self: 'async_trait,

Handle a request by dispatching to the appropriate method Uses Arc for thread-safe concurrent access to controller instance

Provided Methods§

Source

fn dependencies(&self) -> Vec<String>

Dependencies required by this controller (optional)

Source

fn handle_request_dyn<'life0, 'async_trait>( &'life0 self, method_name: String, request: ElifRequest, ) -> Pin<Box<dyn Future<Output = HttpResult<ElifResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Dynamic dispatch method for trait objects This method allows calling controller methods through trait objects by providing a default implementation that performs reflection-like dispatch

Implementors§