public async Task <HttpResponseMessage> InvokeAsync( Func <Task <HttpResponseMessage> > next, HttpRequestMessage httpRequestMessage, IReadOnlyActionInfo actionInfo, InvocationInfo invocationInfo) { if (_logger != null) { var body = httpRequestMessage.Content; var bodyAsString = body == null ? null : await body.ReadAsStringAsync(); _logger.WriteLine("Request:"); _logger.WriteLine($"{httpRequestMessage}"); _logger.WriteLine("Body:"); _logger.WriteLine($"{bodyAsString}"); _logger.WriteLine(""); } var response = await _httpClient.SendAsync(httpRequestMessage); if (_logger != null) { var body = response.Content; var bodyAsString = body == null ? null : await response.Content.ReadAsStringAsync(); _logger.WriteLine("Response:"); _logger.WriteLine($"{response}"); _logger.WriteLine("Body:"); _logger.WriteLine($"{bodyAsString}"); _logger.WriteLine(""); } return(response); }
public async Task <HttpResponseMessage> InvokeAsync( Func <Task <HttpResponseMessage> > next, HttpRequestMessage httpRequestMessage, IReadOnlyActionInfo actionInfo, InvocationInfo invocationInfo) { httpRequestMessage.Headers.Authorization = _authenticationHeaderValue; return(await next()); }
public Task <HttpResponseMessage> Call( HttpRequestMessage httpRequestMessage, IReadOnlyActionInfo actionInfo, InvocationInfo invocationInfo) { var finalPipelinePart = new CallWebAppPipelinePart(_httpClient, _logger); return(HttpRequestPipelineExecutor.Execute(_pipelineParts, finalPipelinePart, httpRequestMessage, actionInfo, invocationInfo)); }
public Task <HttpResponseMessage> InvokeAsync( Func <Task <HttpResponseMessage> > next, HttpRequestMessage httpRequestMessage, IReadOnlyActionInfo actionInfo, InvocationInfo invocationInfo) { httpRequestMessage.RequestUri = new Uri( QueryHelpers.AddQueryString(httpRequestMessage.RequestUri !.ToString(), "properties", $"{string.Join(",", _data)}"), UriKind.Relative); return(next()); }
public Wrapper( IHttpRequestPipelinePart pipelinePartCurrent, Func <Task <HttpResponseMessage> > next, HttpRequestMessage httpRequestMessage, IReadOnlyActionInfo actionInfo, InvocationInfo invocationInfo) { _pipelinePartCurrent = pipelinePartCurrent; _next = next; _httpRequestMessage = httpRequestMessage; _actionInfo = actionInfo; _invocationInfo = invocationInfo; }
public static async Task <HttpResponseMessage> Execute( List <IHttpRequestPipelinePart> pipelineParts, CallWebAppPipelinePart callWebAppPipelinePart, HttpRequestMessage httpRequestMessage, IReadOnlyActionInfo actionInfo, InvocationInfo invocationInfo) { pipelineParts.Reverse(); Wrapper lastCallExecutor = new(callWebAppPipelinePart, null !, httpRequestMessage, actionInfo, invocationInfo); var previous = lastCallExecutor; foreach (var pipelinePart in pipelineParts) { previous = new Wrapper(pipelinePart, previous.Execute, httpRequestMessage, actionInfo, invocationInfo); } return(await previous.Execute()); }