/// <summary>Process the request.</summary> /// <param name="context">The context.</param> /// <returns>An asynchronous result that yields a HttpResponseMessage.</returns> internal static async Task <HttpResponseMessage> Process(HttpContext context) { string fhirServerUrl = ProcessorUtils.GetFhirServerUrlR4(context.Request); if (context.Request.Path.Value.Length > 4) { context.Request.Path = new PathString(context.Request.Path.Value.Substring(3)); } // proxy this call ForwardContext proxiedContext = context.ForwardTo(fhirServerUrl); // send to server and await response HttpResponseMessage response = await proxiedContext.Send().ConfigureAwait(false); // get copies of data when we care switch (context.Request.Method.ToUpperInvariant()) { case "GET": ProcessGet(ref context, ref response); break; default: // ignore break; } // return the originator response, plus any modifications we've done return(response); }
/// <summary>Process the request.</summary> /// <param name="context">The context.</param> /// <returns>An asynchronous result that yields a HttpResponseMessage.</returns> internal static async Task <HttpResponseMessage> Process(HttpContext context) { string fhirServerUrl = ProcessorUtils.GetFhirServerUrlR4(context.Request); // determine if we need to ask the server for a current version of the resource switch (context.Request.Method) { case "PUT": case "POST": case "DELETE": // figure out if we need to ask the server about this break; default: // don't need to check for existing copy break; } if (context.Request.Path.Value.Length > 4) { context.Request.Path = new PathString(context.Request.Path.Value.Substring(3)); } // proxy this call ForwardContext proxiedContext = context.ForwardTo(fhirServerUrl); // send to server and await response HttpResponseMessage response = await proxiedContext.Send().ConfigureAwait(false); //// get copies of data when we care //switch (context.Request.Method.ToUpperInvariant()) //{ // case "PUT": // case "POST": // // grab the message body to look at // string responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); // // run this Encounter through our Subscription Manager // SubscriptionManager.ProcessEncounter(responseContent, response.Headers.Location); // break; // default: // // just proxy // break; //} // return the results of the proxied call return(response); }
/// <summary>Process the request.</summary> /// <param name="context">The context.</param> /// <returns>An asynchronous result that yields a HttpResponseMessage.</returns> internal static async Task <HttpResponseMessage> Process(HttpContext context) { string fhirServerUrl = ProcessorUtils.GetFhirServerUrlR4(context.Request); if (context.Request.Path.Value.Length > 4) { context.Request.Path = new PathString(context.Request.Path.Value.Substring(3)); } // context.Request.Headers["Accept-Encoding"] = ""; // proxy this call ForwardContext proxiedContext = context.ForwardTo(fhirServerUrl); // send to server and await response HttpResponseMessage response = await proxiedContext.Send().ConfigureAwait(false); // get copies of data when we care switch (context.Request.Method.ToUpperInvariant()) { case "PUT": case "POST": // grab the message body to look at string responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) { // run this Encounter through our Subscription Manager SubscriptionManagerR4.ProcessEncounter( responseContent, response.Headers.Location); } break; default: // ignore break; } // return the results of the proxied call return(response); }