diff --git a/.github/workflows/docker_image_linux.yml b/.github/workflows/docker_image_linux.yml index f4f1e1bec..2861aa9d2 100644 --- a/.github/workflows/docker_image_linux.yml +++ b/.github/workflows/docker_image_linux.yml @@ -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}} diff --git a/src/Spark.Engine/Extensions/HttpRequestFhirExtensions.cs b/src/Spark.Engine/Extensions/HttpRequestFhirExtensions.cs index 484454b62..719fb3c4d 100644 --- a/src/Spark.Engine/Extensions/HttpRequestFhirExtensions.cs +++ b/src/Spark.Engine/Extensions/HttpRequestFhirExtensions.cs @@ -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) @@ -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(); diff --git a/src/Spark.Engine/Extensions/NetCore/IServiceCollectionExtensions.cs b/src/Spark.Engine/Extensions/NetCore/IServiceCollectionExtensions.cs index 9edab5ab1..81cc7eaba 100644 --- a/src/Spark.Engine/Extensions/NetCore/IServiceCollectionExtensions.cs +++ b/src/Spark.Engine/Extensions/NetCore/IServiceCollectionExtensions.cs @@ -76,6 +76,9 @@ public static IMvcCoreBuilder AddFhir(this IServiceCollection services, SparkSet services.RemoveAll(); services.TryAddSingleton(); + services.RemoveAll(); + services.TryAddSingleton(); + return builder; } diff --git a/src/Spark.Engine/Formatters/NetCore/BinaryOutputFormatter.cs b/src/Spark.Engine/Formatters/NetCore/BinaryOutputFormatter.cs index 957f0309e..15c111511 100644 --- a/src/Spark.Engine/Formatters/NetCore/BinaryOutputFormatter.cs +++ b/src/Spark.Engine/Formatters/NetCore/BinaryOutputFormatter.cs @@ -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; @@ -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); } } diff --git a/src/Spark.Engine/Formatters/NetCore/ResourceJsonOutputFormatter.cs b/src/Spark.Engine/Formatters/NetCore/ResourceJsonOutputFormatter.cs index bbbb22d34..d3ac67a06 100644 --- a/src/Spark.Engine/Formatters/NetCore/ResourceJsonOutputFormatter.cs +++ b/src/Spark.Engine/Formatters/NetCore/ResourceJsonOutputFormatter.cs @@ -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); } diff --git a/src/Spark.Engine/Formatters/NetCore/ResourceXmlOutputFormatter.cs b/src/Spark.Engine/Formatters/NetCore/ResourceXmlOutputFormatter.cs index 55693f89a..5caf1b9d0 100644 --- a/src/Spark.Engine/Formatters/NetCore/ResourceXmlOutputFormatter.cs +++ b/src/Spark.Engine/Formatters/NetCore/ResourceXmlOutputFormatter.cs @@ -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); } diff --git a/src/Spark.Engine/Spark.Engine.csproj b/src/Spark.Engine/Spark.Engine.csproj index 321a04b74..7dc705776 100644 --- a/src/Spark.Engine/Spark.Engine.csproj +++ b/src/Spark.Engine/Spark.Engine.csproj @@ -3,7 +3,7 @@ netstandard2.0;net461 Spark.Engine.R4 - 1.3.0 + 1.4.0-beta01 Copyright © Firely 2014, © Kufu 2018 Firely and Kufu Firely, Kufu and contributors diff --git a/src/Spark.Mongo/Spark.Mongo.csproj b/src/Spark.Mongo/Spark.Mongo.csproj index 0b248f4cd..fdd9e8928 100644 --- a/src/Spark.Mongo/Spark.Mongo.csproj +++ b/src/Spark.Mongo/Spark.Mongo.csproj @@ -3,7 +3,7 @@ netstandard2.0 Spark.Mongo.R4 - 1.3.0 + 1.4.0-beta01 Copyright © Firely 2014, © Kufu 2018 Firely and Kufu Firely, Kufu and contributors diff --git a/src/Spark.Web/Startup.cs b/src/Spark.Web/Startup.cs index 37a563e92..8926de557 100644 --- a/src/Spark.Web/Startup.cs +++ b/src/Spark.Web/Startup.cs @@ -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 { @@ -55,6 +57,13 @@ public void ConfigureServices(IServiceCollection services) options.MinimumSameSitePolicy = SameSiteMode.None; }); + services.AddResponseCompression(options => + { + options.Providers.Add(); + options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat( + new[] { "application/fhir+json", "application/fhir+xml" }); + }); + // Add database context for user administration services.AddDbContext(options => options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")) diff --git a/src/Spark.Web/appsettings.json b/src/Spark.Web/appsettings.json index c6ec14403..615484269 100644 --- a/src/Spark.Web/appsettings.json +++ b/src/Spark.Web/appsettings.json @@ -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" diff --git a/src/Spark/Properties/AssemblyInfo.cs b/src/Spark/Properties/AssemblyInfo.cs index e8107a9d3..36a204744 100644 --- a/src/Spark/Properties/AssemblyInfo.cs +++ b/src/Spark/Properties/AssemblyInfo.cs @@ -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")] diff --git a/src/Spark/Web.config b/src/Spark/Web.config index 43a491cf7..63082e392 100644 --- a/src/Spark/Web.config +++ b/src/Spark/Web.config @@ -115,10 +115,6 @@ - - - - @@ -167,10 +163,6 @@ - - - - @@ -247,62 +239,46 @@ - - - - - - - - - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - + + + + @@ -317,4 +293,4 @@ - + \ No newline at end of file