Beispiel #1
0
        /// <summary>  </summary>
        public async Task Call <TRequest, TResponse>(IContext ctx, TRequest request, [NotNull] Pipe.ExecuteAsync <TResponse> onResponse, Pipe.ExecuteAsync <Exception>?onError = null)
        {
            var responseBuilder = Pipe.Builder <TResponse>().UseAsync(onResponse);
            var errorBuilder    = onError == null ? null : Pipe.Builder <Exception>().UseAsync(onError);

            await Call(ctx, request, responseBuilder, errorBuilder);
        }
Beispiel #2
0
        private async Task AccessDenied(IContext ctx, Request value, Pipe.ExecuteAsync <Request> next)
        {
            var p    = ctx.GetPrincipal();
            var role = p.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Role)?.Value ?? "?";
            await Console.Out.WriteLineAsync($"Access denied for user '{p.Identity!.Name}' in role '{role}'");

            await next(ctx, value);
        }
Beispiel #3
0
 public Pipe(Pipe.ExecuteAsync <T> executeAsync, IPipe <T> next, string?name)
 {
     _executeAsync = executeAsync;
     _next         = next;
     _name         = name ?? GenerateName();
 }
Beispiel #4
0
 /// <summary>
 /// Adds the <paramref name="executeAsyncAsync"/> delegate in the pipeline
 /// and unconditionally executes the next pipe
 /// </summary>
 public static IBuilder <TIn, TOut> UseAsync <TIn, TOut>(this IBuilder <TIn, TOut> builder, Pipe.ExecuteAsync <TOut> executeAsyncAsync, string?name = null)
 {
     return(builder.Use(next => new Pipe <TOut>(executeAsyncAsync, next, name), name));
 }