Add Mediator endpoint route builder extensions and refactor SendEndpointRequestFilter
This commit is contained in:
parent
96018137cc
commit
544d23a397
@ -0,0 +1,17 @@
|
|||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
|
namespace Baguette.Extensions.AspNetCore.Mediator;
|
||||||
|
|
||||||
|
public static class MediatorEndpointRouteBuilderExtensions
|
||||||
|
{
|
||||||
|
public static RouteHandlerBuilder SendRequest<TResponse>(this RouteHandlerBuilder builder)
|
||||||
|
{
|
||||||
|
return builder.AddEndpointFilter<SendEndpointRequestFilter<TResponse>>().Produces<TResponse>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RouteHandlerBuilder SendRequest(this RouteHandlerBuilder builder)
|
||||||
|
{
|
||||||
|
return builder.AddEndpointFilter<SendEndpointRequestFilter>().Produces(StatusCodes.Status200OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
@ -39,16 +38,3 @@ public class SendEndpointRequestFilter : IEndpointFilter
|
|||||||
: throw new InvalidOperationException(); // TODO: Handle case where request can't be sent
|
: throw new InvalidOperationException(); // TODO: Handle case where request can't be sent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MediatorEndpointRouteBuilderExtensions
|
|
||||||
{
|
|
||||||
public static RouteHandlerBuilder SendRequest<TResponse>(this RouteHandlerBuilder builder)
|
|
||||||
{
|
|
||||||
return builder.AddEndpointFilter<SendEndpointRequestFilter<TResponse>>().Produces<TResponse>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RouteHandlerBuilder SendRequest(this RouteHandlerBuilder builder)
|
|
||||||
{
|
|
||||||
return builder.AddEndpointFilter<SendEndpointRequestFilter>().Produces(StatusCodes.Status200OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user