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§
- IClaims
Carrier - Blanket trait that enables claims injection on request structs.
- IEvent
Handler - Handles a single
IEventRequest, performing side effects. - IHosted
Service - Background service that is started when the host starts and stopped when the host performs a graceful shutdown.
- IRequest
Handler - Handles a single
IRequest<R>, producing its associated responseR.