Interface ICommandMiddleware<TCommand, TResult>
interface for creating a command middleware used to build a pipeline around command handlers.
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public interface ICommandMiddleware<in TCommand, TResult> where TCommand : ICommand<TResult>
Type Parameters
Name | Description |
---|---|
TCommand | the type of the command |
TResult | the type of the result |
Methods
ExecuteAsync(TCommand, CommandDelegate<TResult>, CancellationToken)
implement this method to run some common piece of logic for all command handlers.
make sure to execute the next
delegate within your logic in order to no break the pipeline.
Declaration
Task<TResult> ExecuteAsync(TCommand command, CommandDelegate<TResult> next, CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
TCommand | command | the command instance |
CommandDelegate<TResult> | next | the command delegate to execute next |
CancellationToken | ct | cancellation token |
Returns
Type | Description |
---|---|
Task<TResult> |