public async Task ConvertResponse <T>(ServiceResponse <T> response, HttpResponse httpResponse, HttpDataSerializerOptions options) where T : new() { var serializedData = await _serializer.SerializeResponse(response, typeof(ServiceResponse <T>), options); var contentType = _serializer.ContentType; var encoding = _serializer.Encoding; httpResponse.StatusCode = response.MetaData.Result.HttpStatusCode(); httpResponse.ContentType = contentType; await httpResponse.WriteAsync(serializedData, encoding); }
public async Task <HttpResponseMessage> ConvertResponse(HttpRequestMessage request, ServiceResponse response, Type type) { var options = CreateOptionsFromHeaders(request.Headers); var serializedData = await _serializer.SerializeResponse(response, type, options); var contentType = _serializer.ContentType; var encoding = _serializer.Encoding; var httpMsg = new HttpResponseMessage { StatusCode = (HttpStatusCode)response.MetaData.Result.HttpStatusCode(), Content = new StringContent(serializedData, encoding, contentType) }; httpMsg.Headers.Add(nameof(response.MetaData.CorrelationId), $"{response.MetaData.CorrelationId}"); return(httpMsg); }