Skip to main content

erase_handler_with_state

Macro erase_handler_with_state 

Source
macro_rules! erase_handler_with_state {
    ($handler:expr, $state_ty:ty, $args_ty:ty, $states:expr) => { ... };
}
Expand description

Erase a handler with state + typed args into an ErasedHandler.

The handler must be an async fn(State<Arc<S>>, T) -> R.

§Example

use allframe_core::{erase_handler_with_state, router::Router};

#[allframe_macros::allframe_handler]
async fn get_user(
    state: State<Arc<AppState>>,
    args: GetUserArgs,
) -> Result<User, MyError> { todo!() }

let mut router = Router::new();
let states = router.shared_states();
router.register_erased(
    "get_user",
    erase_handler_with_state!(get_user, AppState, GetUserArgs, states),
);