public static MiddlewareData AddResponseRenderer(this MiddlewareData data, Action <MessageData.MessageDataBuilder> action)
        {
            var builder = MessageData.Builder();

            action(builder);
            return(data.AddRenderer(new ResponseMessageRenderer(builder.Build())));
        }
 public static MiddlewareData AddResponseRenderer(this MiddlewareData data, string text)
 {
     return(data.AddRenderer(new ResponseMessageRenderer(new MessageData()
     {
         Text = text
     })));
 }
            public async Task <MiddlewareData> NextAsync(MiddlewareData data)
            {
                _stopwatch.Stop();
                var result = await _next.NextAsync(data);

                _stopwatch.Start();
                return(result);
            }
 public async Task <MiddlewareData> InvokeAsync(MiddlewareData data, IMiddlewaresChain chain)
 {
     try {
         return(await chain.NextAsync(data));
     }
     catch (Exception e) {
         _logger.LogError(0, e, "Unexpected error occurred");
         return(data.AddResponseRenderer($"Error occured: [{e.GetType().Name}] {e.Message}"));
     }
 }
            public async Task <MiddlewareData> NextAsync(MiddlewareData data)
            {
                var sw = new Stopwatch();

                sw.Start();
                var result = await GetInstance().InvokeAsync(data, new TimerChainElement(sw, _next));

                sw.Stop();

                _logger.LogDebug($"Middleware {(_instance?.GetType() ?? _type).Name} completed in {sw.ElapsedMilliseconds} ms ()");

                return(result);
            }
 public static MiddlewareData AddResponseRenderer(this MiddlewareData data, MessageData messageData)
 {
     return(data.AddRenderer(new ResponseMessageRenderer(messageData)));
 }
 public Task <MiddlewareData> NextAsync(MiddlewareData data)
 {
     return(Task.FromResult(data));
 }