Пример #1
0
        public void CreateRoutes(IApplicationBuilder applicationBuilder)
        {
            _imposterRoute.CreateImposterResourceRoutes(
                applicationBuilder,
                _configuration.Imposters,
                EvaluateImposterRules
                );

            RequestDelegate EvaluateImposterRules(Imposter imposter)
            {
                return(async context =>
                {
                    await EvaluateRules(imposter, context);
                });
            }

            async Task EvaluateRules(Imposter imposter,
                                     HttpContext context)
            {
                var request = BuildRequest(context);

                var(response, _)
                    = _rulesEvaluator.EvaluateRules(
                          imposter,
                          context,
                          request
                          );

                context.Response.StatusCode = response.StatusCode;
                await context.Response.WriteAsync(response.Content);
            }
        }
Пример #2
0
        private async Task EvaluateRules(Imposter imposter,
                                         HttpContext context)
        {
            var request = BuildRequest(context);

            var(response, matchedCondition) = _rulesEvaluator.EvaluateRules(imposter,
                                                                            context,
                                                                            request);

            StoreRequestAndResponse(imposter, request, response, matchedCondition);

            context.Response.StatusCode = response.StatusCode;
            await context.Response.WriteAsync(response.Content);
        }