コード例 #1
0
        protected override Task<HttpResponseMessage> SendAsync(
            HttpRequestMessage request, 
            CancellationToken cancellationToken) {
            
            //Play with the request here

            return base.SendAsync(request, cancellationToken)
                .Then(response => {

                    //Add the X-Magic header
                    response.Headers.Add("X-Magic", "ThisIsMagic");
                    return response;

                }).Catch<HttpResponseMessage>(info => {

                    var cacthResult = 
                        new CatchInfoBase<Task<HttpResponseMessage>>.CatchResult();

                    cacthResult.Task = TaskHelpers.FromResult(
                        request.CreateErrorResponse(
                            HttpStatusCode.InternalServerError, info.Exception));

                    return cacthResult;
                });
        }
コード例 #2
0
        protected override Task <HttpResponseMessage> SendAsync(
            HttpRequestMessage request, CancellationToken cancellationToken)
        {
            return(base.SendAsync(request, cancellationToken).Catch <HttpResponseMessage>(info => {
                var cacthResult =
                    new CatchInfoBase <Task <HttpResponseMessage> > .CatchResult();

                cacthResult.Task = TaskHelpers.FromResult(
                    request.CreateErrorResponse(
                        HttpStatusCode.InternalServerError, info.Exception));

                return cacthResult;
            }));
        }
コード例 #3
0
        protected override Task<HttpResponseMessage> SendAsync(
            HttpRequestMessage request, CancellationToken cancellationToken) {

            return base.SendAsync(request, cancellationToken).Catch<HttpResponseMessage>(info => {

                var cacthResult =
                    new CatchInfoBase<Task<HttpResponseMessage>>.CatchResult();

                cacthResult.Task = TaskHelpers.FromResult(
                    request.CreateErrorResponse(
                        HttpStatusCode.InternalServerError, info.Exception));

                return cacthResult;
            });
        }
コード例 #4
0
        protected override Task <HttpResponseMessage> SendAsync(
            HttpRequestMessage request,
            CancellationToken cancellationToken)
        {
            //Play with the request here

            return(base.SendAsync(request, cancellationToken)
                   .Then(response => {
                //Add the X-Magic header
                response.Headers.Add("X-Magic", "ThisIsMagic");
                return response;
            }).Catch <HttpResponseMessage>(info => {
                var cacthResult =
                    new CatchInfoBase <Task <HttpResponseMessage> > .CatchResult();

                cacthResult.Task = TaskHelpers.FromResult(
                    request.CreateErrorResponse(
                        HttpStatusCode.InternalServerError, info.Exception));

                return cacthResult;
            }));
        }