Sponsorship is available! If you’d like to sponsor CodeOpinion.com and have your product or service advertised exclusively (no AdSense) on every post, contact me.With the MediatR v3, there is the ability to create your own request pipelines. To help out of the box, there are some predefined behaviors to help out with commen tasks such as pre and post request. These are
RequestPostProcessorBehavior<,>I’ve blogged about the new behaviors before but you can do it more generically.
Cross Cutting Behavior
I was looking at the pipeline to handle cross-cutting concerns like logging and metrics, which I would want on each command/query.— Scott Banwart (@sbanwart) September 6, 2017
LoggingPretty typical scenario of wanting to log incoming requests. One common use case would be to store the incoming requests as a message store.
RegistrationThe next piece of the puzzle is making sure you register the
RequestPreProcessorBehavior<,>with the DI container you are using with MediatR. In the case of StructureMap that looks like: