Exemplo n.º 1
0
        public async Task <MiddlewareData> InvokeAsync(MiddlewareData data, IMiddlewaresChain chain)
        {
            foreach (var handler in _handlerFactory.CreateHandlers(data))
            {
                var result = await handler.ExecuteAsync(data);

                if (result == null)   // TODO fix this check
                {
                    continue;
                }
                var resultData = await result.RenderAsync(data);

                return(await chain.NextAsync(resultData));
            }

            throw new NoSuchHandlerException();
        }