public async Task Invoke(HttpContext httpContext) { IWorkContext workContext = httpContext.Items.Get <IWorkContext>() ?? WorkContext.Empty; var builder = new WorkContextBuilder(workContext); builder.SetContainer(_serviceConfiguration.Container); foreach (var item in httpContext.Request.Headers) { var property = _headerFactory.Create(item.Key, item.Value); if (property != null) { builder.Properties.Set(property, derivedType: property.GetType()); } } // Correlation Vector var headerCv = builder.Properties.Get <CvHeader>(); if (headerCv != null) { builder.Cv = new CorrelationVector(headerCv.Value); } workContext = builder.Build(); Uri url = new Uri(httpContext.Request.GetEncodedUrl()); var requestContext = new RequestContext(workContext, httpContext.Request.Method, url); httpContext.Items.Set(requestContext); using (var scope = new TimerScope( () => _webLogEvent.HttpRequestStart(workContext, requestContext), (x) => _webLogEvent.HttpRequestStop(workContext, requestContext, x))) { await _next.Invoke(httpContext); if (httpContext?.Response?.StatusCode != null) { AspMvcEventSource.Log.Verbose(workContext, $"REST response result: {httpContext.Response.StatusCode}"); } } }
public void Execute(int requestId, string name, string value) { if (name == null) { throw new ArgumentNullException(nameof(name), "The name property is not nullable"); } if (value == null) { throw new ArgumentNullException(nameof(value), "The value property is not nullable"); } var request = _uow.Requests.Include(c => c.Headers).Single(c => c.Id == requestId); var domainObject = _factory.Create(name, value); request.Headers.Add(_dataFactory.Create(domainObject)); _uow.Requests.Update(request); _uow.SaveChanges(); }