Skip to content

Commit

Permalink
Add workaround for Giraffe bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeeren committed Jun 5, 2020
1 parent 76ff9ad commit d71f0b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Felicity.IntegrationTests/PatchResource.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Felicity/Felicity.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>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</PackageTags>
<PackageIcon>felicity-logo-128x128.png</PackageIcon>
<Version>0.8.2</Version>
<PackageReleaseNotes>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)</PackageReleaseNotes>
<Version>0.8.3</Version>
<PackageReleaseNotes>Added workaround for Giraffe bug (https://github.com/giraffe-fsharp/Giraffe/issues/424)</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
Expand Down
5 changes: 4 additions & 1 deletion src/Felicity/Operations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d71f0b8

Please sign in to comment.