From d71f0b8ae00ad4038e522baf17fc5c6b70483640 Mon Sep 17 00:00:00 2001 From: Christer van der Meeren Date: Fri, 5 Jun 2020 08:34:23 +0200 Subject: [PATCH] Add workaround for Giraffe bug https://github.com/giraffe-fsharp/Giraffe/issues/424 --- README.md | 4 ++++ src/Felicity.IntegrationTests/PatchResource.fs | 2 +- src/Felicity/Felicity.fsproj | 4 ++-- src/Felicity/Operations.fs | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8b4b209..c71c6fc 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,10 @@ That’s it! You now have a wonderfully compliant JSON:API exposing your wonderf Release notes ------------- +### 0.8.3 (2020-06-05) + +* Added workaround for [giraffe-fsharp/Giraffe#24](https://github.com/giraffe-fsharp/Giraffe/issues/424) + ### 0.8.2 (2020-05-21) * Enabled lookup of arbitrary types in `myRelationship.Related()` parsers (was previously restricted to the relationship’s related entity type, now allows lookups of e.g. simpler resource projections, or simple existence checks for the related IDs) diff --git a/src/Felicity.IntegrationTests/PatchResource.fs b/src/Felicity.IntegrationTests/PatchResource.fs index 1a31ba0..9453473 100644 --- a/src/Felicity.IntegrationTests/PatchResource.fs +++ b/src/Felicity.IntegrationTests/PatchResource.fs @@ -262,7 +262,7 @@ module A5 = let lookup = define.Operation.Lookup(fun _ -> Some { Id = "a1"; ReadOnly = ""; A = false; X = ""; Nullable = None; NullableNotNullWhenSet = None }) let get = define.Operation.GetResource() let patch = define.Operation.Patch().AfterUpdate(ignore) - let preconditions = define.Preconditions.LastModified(fun _ -> DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero)) + let preconditions = define.Preconditions.LastModified(fun _ -> DateTimeOffset(2000, 1, 1, 0, 0, 0, 999, TimeSpan.Zero)) // Should ignore milliseconds type Ctx6 = Ctx6 diff --git a/src/Felicity/Felicity.fsproj b/src/Felicity/Felicity.fsproj index 0cdcdd1..c37bb77 100644 --- a/src/Felicity/Felicity.fsproj +++ b/src/Felicity/Felicity.fsproj @@ -13,8 +13,8 @@ MIT f# fsharp jsonapi json-api json:api api rest rest-api api-rest api-server api-client web-api asp-net-core aspnetcore giraffe framework felicity-logo-128x128.png - 0.8.2 - Enabled lookup of arbitrary types in myRelationship.Related() parsers (was previously restricted to the relationship’s related entity type, now allows lookups of e.g. simpler resource projections, or simple existence checks for the related IDs) + 0.8.3 + Added workaround for Giraffe bug (https://github.com/giraffe-fsharp/Giraffe/issues/424) diff --git a/src/Felicity/Operations.fs b/src/Felicity/Operations.fs index 0c5116a..bb509f8 100644 --- a/src/Felicity/Operations.fs +++ b/src/Felicity/Operations.fs @@ -31,7 +31,10 @@ type Preconditions<'ctx, 'entity> = internal { interface Preconditions<'ctx> with member this.Validate httpCtx ctx entity = let eTag = this.getETag ctx (unbox<'entity> entity) - let lastModified = this.getLastModified ctx (unbox<'entity> entity) + let lastModified = + this.getLastModified ctx (unbox<'entity> entity) + // Workaround for https://github.com/giraffe-fsharp/Giraffe/issues/424 + |> Option.map (fun dt -> dt.AddMilliseconds (float (-dt.Millisecond))) let res = httpCtx.ValidatePreconditions eTag lastModified // Clear headers because response-level ETag/Last-Modified headers don't // necessarily make sense in JSON:API due to compound documents; these values