예제 #1
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            if (request.RequestUri.LocalPath.Contains("swagger"))
            {
                return(await base.SendAsync(request, cancellationToken));
            }

            var requestMetadata = BuildRequestMetadata(request);
            var response        = await base.SendAsync(request, cancellationToken);

            var responseMetada = BuildResponseMetadata(response);

            LogApi logApi = new LogApi
            {
                Request  = requestMetadata,
                Response = responseMetada
            };

            await SendToLog(logApi);

            return(response);
        }
예제 #2
0
 /// <summary>
 /// Persiste los datos trazados en una bd, archivo, etc
 /// </summary>
 /// <param name="logMetadata"></param>
 /// <returns></returns>
 private async Task <bool> SendToLog(LogApi logMetadata)
 {
     LogError(JsonConvert.SerializeObject(logMetadata, Formatting.Indented));
     return(true);
 }