Skip to main content

Module handler

Module handler 

Source
Expand description

Handler traits: IRequestHandler and IEventHandler.

§IRequestHandler<T, R>

Dual-type-parameter handler: T is the request type, R is the response type. The constraint T: IRequest<R> ensures type safety between request and response.

handle takes &mut self so handlers that own a DbContext (resolved via get_owned — EFCore-style per-request unit-of-work) can call ctx.set::<T>() and ctx.save_changes() which require &mut self.

#[async_trait]
impl IRequestHandler<GetUserRequest, UserModel> for GetUserHandler {
    async fn handle(&mut self, req: GetUserRequest) -> Result<UserModel> { ... }
}

Traits§

IClaimsCarrier
Blanket trait that enables claims injection on request structs.
IEventHandler
Handles a single IEventRequest, performing side effects.
IHostedService
Background service that is started when the host starts and stopped when the host performs a graceful shutdown.
IRequestHandler
Handles a single IRequest<R>, producing its associated response R.