public async Task Invoke(HttpContext httpContext)
        {
            var downstreamRoute = httpContext.Items.DownstreamRoute();

            var preFAndRs = downstreamRoute.UpstreamHeadersFindAndReplace;

            //todo - this should be on httprequestmessage not httpcontext?
            _preReplacer.Replace(httpContext, preFAndRs);

            _addHeadersToRequest.SetHeadersOnDownstreamRequest(downstreamRoute.AddHeadersToUpstream, httpContext);

            await _next.Invoke(httpContext);

            // todo check errors is ok
            //todo put this check on the base class?
            if (httpContext.Items.Errors().Count > 0)
            {
                return;
            }

            var postFAndRs = downstreamRoute.DownstreamHeadersFindAndReplace;

            _postReplacer.Replace(httpContext, postFAndRs);

            var downstreamResponse = httpContext.Items.DownstreamResponse();

            _addHeadersToResponse.Add(downstreamRoute.AddHeadersToDownstream, downstreamResponse);
        }
Example #2
0
        public async Task Invoke(HttpContext context)
        {
            var preFAndRs = this.DownstreamRoute.ReRoute.UpstreamHeadersFindAndReplace;

            _preReplacer.Replace(context, preFAndRs);

            await _next.Invoke(context);

            var postFAndRs = this.DownstreamRoute.ReRoute.DownstreamHeadersFindAndReplace;

            _postReplacer.Replace(HttpResponseMessage, postFAndRs);
        }
        public async Task Invoke(DownstreamContext context)
        {
            var preFAndRs = context.DownstreamReRoute.UpstreamHeadersFindAndReplace;

            //todo - this should be on httprequestmessage not httpcontext?
            _preReplacer.Replace(context.HttpContext, preFAndRs);

            await _next.Invoke(context);

            var postFAndRs = context.DownstreamReRoute.DownstreamHeadersFindAndReplace;

            _postReplacer.Replace(context.DownstreamResponse, postFAndRs, context.DownstreamRequest);
        }
        public async Task Invoke(DownstreamContext context)
        {
            var preFAndRs = context.DownstreamReRoute.UpstreamHeadersFindAndReplace;

            //todo - this should be on httprequestmessage not httpcontext?
            _preReplacer.Replace(context.HttpContext, preFAndRs);

            _addHeadersToRequest.SetHeadersOnDownstreamRequest(context.DownstreamReRoute.AddHeadersToUpstream, context.HttpContext);

            await _next.Invoke(context);

            if (context.IsError)
            {
                return;
            }

            var postFAndRs = context.DownstreamReRoute.DownstreamHeadersFindAndReplace;

            _postReplacer.Replace(context.DownstreamResponse, postFAndRs, context.DownstreamRequest);

            _addHeadersToResponse.Add(context.DownstreamReRoute.AddHeadersToDownstream, context.DownstreamResponse);
        }