public IDispatcherWithDtoEndpointsBuilder Post(string path, Func <HttpContext, Task>?context = null, Action <IEndpointConventionBuilder>?endpoint = null, bool auth = false, string?roles = null, params string[] policies) { _builder.Post(path, context, endpoint, auth, roles, policies); return(this); }
public IExtendedDispatcherEndpointsBuilder Post <TRequest, TResult>(string path, Func <TRequest, TResult, HttpContext, Task> afterDispatch = null, Action <IEndpointConventionBuilder> endpoint = null, bool auth = false, string roles = null, params string[] policies) where TRequest : class, IRequest { _builder.Post <TRequest>(path, async(request, ctx) => { var dispatcher = ctx.RequestServices.GetRequiredService <IRequestDispatcher>(); var result = await dispatcher.DispatchAsync <TRequest, TResult>(request); if (afterDispatch is null) { if (result is null) { ctx.Response.StatusCode = 404; return; } await ctx.Response.WriteJsonAsync(result); return; } await afterDispatch(request, result, ctx); }, endpoint, auth, roles, policies); return(this); }
public IDispatcherEndpointsBuilder Post(string path, Func <HttpContext, Task> context = null) { _builder.Post(path, context); return(this); }