Skip to content

Commit

Permalink
Merge branch 'stu3/develop' into r4/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethmyhra committed Mar 8, 2020
2 parents eee59d7 + 413bc8e commit 8cdc3b3
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker_image_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
-t ${{ secrets.DOCKERHUB_USERNAME }}/spark:${{steps.vars.outputs.tag}}
-t ${{ secrets.DOCKERHUB_USERNAME }}/spark:r4-latest-develop
- name: Push the tagged Spark Docker image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/spark:${{steps.vars.outputs.tag}}
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/spark
- name: Build the tagged Mongo Docker image
run: docker build . --file .docker/linux/Mongo.Dockerfile
-t ${{ secrets.DOCKERHUB_USERNAME }}/mongo:${{steps.vars.outputs.tag}}
Expand Down
23 changes: 22 additions & 1 deletion src/Spark.Engine/Extensions/HttpRequestFhirExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,27 @@ internal static bool IsRawBinaryPostOrPutRequest(this HttpRequest request)
&& !HttpRequestExtensions.IsContentTypeHeaderFhirMediaType(request.ContentType)
&& (request.Method == "POST" || request.Method == "PUT");
}

internal static void AcquireHeaders(this HttpResponse response, FhirResponse fhirResponse)
{
if (fhirResponse.Key != null)
{
response.Headers.Add("ETag", ETag.Create(fhirResponse.Key.VersionId)?.ToString());

Uri location = fhirResponse.Key.ToUri();
response.Headers.Add("Location", location.OriginalString);

if (response.Body != null)
{
response.Headers.Add("Content-Location", location.OriginalString);
if (fhirResponse.Resource != null && fhirResponse.Resource.Meta != null)
{
response.Headers.Add("Last-Modified", fhirResponse.Resource.Meta.LastUpdated.Value.ToString("R"));
}
}
}
}

#endif

internal static void AcquireHeaders(this HttpResponseMessage response, FhirResponse fhirResponse)
Expand All @@ -166,7 +187,7 @@ internal static void AcquireHeaders(this HttpResponseMessage response, FhirRespo
}
}
}

private static HttpResponseMessage CreateBareFhirResponse(this HttpRequestMessage request, FhirResponse fhir)
{
bool includebody = request.PreferRepresentation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public static IMvcCoreBuilder AddFhir(this IServiceCollection services, SparkSet
services.RemoveAll<OutputFormatterSelector>();
services.TryAddSingleton<OutputFormatterSelector, FhirOutputFormatterSelector>();

services.RemoveAll<OutputFormatterSelector>();
services.TryAddSingleton<OutputFormatterSelector, FhirOutputFormatterSelector>();

return builder;
}

Expand Down
8 changes: 7 additions & 1 deletion src/Spark.Engine/Formatters/NetCore/BinaryOutputFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using FhirModel = Hl7.Fhir.Model;
using Microsoft.AspNetCore.Mvc.Formatters;
using Spark.Engine.Core;
using Spark.Engine.Extensions;
using System;
using System.IO;
using System.Threading.Tasks;
Expand All @@ -28,12 +29,17 @@ public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext co
if (typeof(FhirResponse).IsAssignableFrom(context.ObjectType))
{
FhirResponse response = (FhirResponse)context.Object;

context.HttpContext.Response.AcquireHeaders(response);
context.HttpContext.Response.StatusCode = (int)response.StatusCode;

binary = response.Resource as FhirModel.Binary;
}
if (binary == null) return;

Stream stream = new MemoryStream(binary.Data);
context.HttpContext.Response.ContentType = binary.ContentType;

Stream stream = new MemoryStream(binary.Data);
await stream.CopyToAsync(context.HttpContext.Response.Body);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context,
if (typeof(FhirResponse).IsAssignableFrom(context.ObjectType))
{
FhirResponse response = context.Object as FhirResponse;

context.HttpContext.Response.AcquireHeaders(response);
context.HttpContext.Response.StatusCode = (int)response.StatusCode;

if (response.Resource != null)
serializer.Serialize(response.Resource, jsonWriter, summaryType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context,
if (typeof(FhirResponse).IsAssignableFrom(context.ObjectType))
{
FhirResponse response = context.Object as FhirResponse;

context.HttpContext.Response.AcquireHeaders(response);
context.HttpContext.Response.StatusCode = (int)response.StatusCode;

if (response.Resource != null)
serializer.Serialize(response.Resource, xmlWriter, summaryType);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Spark.Engine/Spark.Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<PackageId>Spark.Engine.R4</PackageId>
<Version>1.3.0</Version>
<Version>1.4.0-beta01</Version>
<Copyright>Copyright © Firely 2014, © Kufu 2018</Copyright>
<Company>Firely and Kufu</Company>
<Authors>Firely, Kufu and contributors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/Spark.Mongo/Spark.Mongo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>Spark.Mongo.R4</PackageId>
<Version>1.3.0</Version>
<Version>1.4.0-beta01</Version>
<Copyright>Copyright © Firely 2014, © Kufu 2018</Copyright>
<Company>Firely and Kufu</Company>
<Authors>Firely, Kufu and contributors</Authors>
Expand Down
9 changes: 9 additions & 0 deletions src/Spark.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using Spark.Web.Services;
using Spark.Web.Hubs;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.AspNetCore.ResponseCompression;
using System.Linq;

namespace Spark.Web
{
Expand Down Expand Up @@ -55,6 +57,13 @@ public void ConfigureServices(IServiceCollection services)
options.MinimumSameSitePolicy = SameSiteMode.None;
});

services.AddResponseCompression(options =>
{
options.Providers.Add<GzipCompressionProvider>();
options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
new[] { "application/fhir+json", "application/fhir+xml" });
});

// Add database context for user administration
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlite(Configuration.GetConnectionString("DefaultConnection"))
Expand Down
2 changes: 1 addition & 1 deletion src/Spark.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"DefaultConnection": "Data Source=database.db"
},
"StoreSettings": {
"ConnectionString": "mongodb://root:CosmicTopSecret@localhost:27017/spark?authSource=admin"
"ConnectionString": "mongodb://localhost:27017/spark"
},
"SparkSettings": {
"Endpoint": "https://localhost:5001/fhir"
Expand Down
2 changes: 1 addition & 1 deletion src/Spark/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("14.8.0.0")]
[assembly: AssemblyVersion("14.9.0.0")]

54 changes: 15 additions & 39 deletions src/Spark/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@
<assemblyIdentity name="System.Runtime.Numerics" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
Expand Down Expand Up @@ -167,10 +163,6 @@
<assemblyIdentity name="System.Net.NetworkInformation" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Linq.Queryable" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
Expand Down Expand Up @@ -247,62 +239,46 @@
<assemblyIdentity name="System.Collections.Concurrent" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30AD4FE6B2A6AEED" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0" />
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="EB42632606E9261F" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
Expand All @@ -317,4 +293,4 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
</configuration>

0 comments on commit 8cdc3b3

Please sign in to comment.