MediatR
MediatR copied to clipboard
Is it possible to access the innermost request handler from pipeline behavior?
For example, I'd like to do some conditional global handling based on the request handler. Has the handler instance been created and accessible at this moment?
Hi @nicholasyin Could you please provide more details?
I have a TransactionBehavior implementing the IPipelineBehavior
interface and wrapping around all the inner behaviors and handlers. Its handler method is like this:
public async Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate<TResponse> next)
{
}
So inside this method, is it possible to get access to the inside real request handler?
I have a similar problem. I have different Behaviours, registered as generic pipeline behaviours. All of them are global. I want to use some of them for one group of handlers and the other for the second group of handlers. There is no ability to do this directly now. So, It could be a good ability to get the currently executed handler for, for example, an attribute or marker interface realization for the current handler to skip some of them.