Last active
September 16, 2022 23:45
-
-
Save wellingtonjhn/e7c07f8116b47247592c88cb9d831b38 to your computer and use it in GitHub Desktop.
MediatR Pipeline Behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LoggingBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> | |
| { | |
| public async Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate<TResponse> next) | |
| { | |
| await Logger.InfoAsync($"Handling {typeof(TRequest).Name}"); | |
| var response = await next(); | |
| await Logger.InfoAsync($"Handled {typeof(TResponse).Name}"); | |
| return response; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment