コード例 #1
0
        public async Task <HttpCallingAuditingInfo> CreateAuditingInfo(string trackId, HttpRequestMessage request, double executionDuration,
                                                                       HttpStatusCode statusCode, HttpResponseMessage response)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (response == null)
            {
                throw new ArgumentNullException(nameof(response));
            }
            if (trackId == null)
            {
                trackId = Guid.NewGuid().ToString("N");
            }

            var auditingInfo = new HttpCallingAuditingInfo();

            auditingInfo.RemoteApiUrl   = request.RequestUri.ToString();
            auditingInfo.TrackId        = trackId;
            auditingInfo.HttpMethod     = request.Method.Method;
            auditingInfo.RequestHeaders = new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Request, request.Headers, request.Content?.Headers).ToString();
            auditingInfo.RequestBody    = await request.Content?.ReadAsStringAsync();

            auditingInfo.ExecutionDuration = executionDuration;

            auditingInfo.HttpStatusCode  = (int)response.StatusCode;
            auditingInfo.ResponseHeaders = new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Response, response.Headers, response.Content?.Headers).ToString();
            auditingInfo.ResponseBody    = await response.Content?.ReadAsStringAsync();

            return(auditingInfo);
        }
コード例 #2
0
 public Task SaveAsync(HttpCallingAuditingInfo info)
 {
     if (info == null)
     {
         throw new ArgumentNullException(nameof(info));
     }
     return(_auditingStore.SaveAsync(info));
 }
コード例 #3
0
 public Task SaveAsync(HttpCallingAuditingInfo info)
 {
     return(Task.CompletedTask);
 }