Ejemplo n.º 1
0
        /// <inheritdoc/>
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var result = await base.SendAsync(request, cancellationToken);

            JsonApiProcessor.ProcessRequest(request, result, _config, requiresMediaType: true);

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// See base class documentation.
        /// </summary>
        /// <param name="context">The action context.</param>
        public override void OnActionExecuted(HttpActionExecutedContext context)
        {
            if (context.Exception != null)
            {
                throw context.Exception;
            }

            JsonApiProcessor.ProcessRequest(context.Request, context.Response, JsonApiConfiguration, requiresMediaType: false);

            var responseContent = context.Response.Content as ObjectContent;

            if (responseContent == null)
            {
                return;
            }

            var formatter = new JsonApiMediaTypeFormatter(context.Request, JsonApiConfiguration);

            context.Response.Content = new ObjectContent(responseContent.ObjectType, responseContent.Value, formatter);
        }