Question regarding IPipelineBehavior
See original GitHub issueHi, I’m trying to use the IPipelineBehavior in a very specific way and (probably - likely - very much) I’m missing something because it is not working.
All my requests are of type IRequest<OperationResult>
or IRequest<OperationResult<TResult>>
. OperationResult is a class that’s basically a way for me to return a (possible) failed result, with errors, and if the result is not failed, a way to attach a value to it (the generic version).
Now, I want to add in a pipeline so I can short-circuit the flow if some condition is met.
I then defined my pipeline like this:
public sealed class AuthorizationBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, OperationResult<TResponse>> where TRequest : class, IRequest<OperationResult<TResponse>>
but on execution that throws because TResponse is not the type I want (the result type), but the type of the IResult<T>.
Of course that I can’t define an AuthorizationBehavior<TRequest, OperationResult<TResponse>>
. That’s not valid. So, I’m blind right now as I don’t know how to define the pipeline in order for me to be able to short-circuit it, without throwing an exception, and be able to return my own OperationResult<TResponse> inside the handler if I need to…
Any hints or ideas? Maybe I’m using this wrong and I have to do it in another way?
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (5 by maintainers)
Top GitHub Comments
Yes! I should blog about this more 😛
On Thu, Nov 16, 2017 at 11:29 AM, Ricardo Peres notifications@github.com wrote:
Oops, figured it out finally!
For others to reference, here is how I setup my validation pipeline behavior to return result metadata:
Feedback is welcome!