Json Api types and basic implementations.
Add following into paket.references
Alma.JsonApi
Trace.Http.finishTraceHandler will be called after a jsonApi finish the HttpContext, it will finish current active trace and set a real http.status_code as a tag
let webApp =
choose [
Trace.Http.finishTraceHandler
>=> jsonApi<JsonApiContext>
]Note: Do not forget that you need to start an active trace as a HttpScopedTrace.
let post =
define.Operation
.Post(fun ctx parser ->
asyncResult {
let postOperationTrace = ctx.HttpContext |> Trace.Http.start "Post Operation" // start current active trace
use _ = "Create resource" |> Trace.ChildOf.start postOperationTrace.Trace // trace create resource as a child of the active trace
// ... create resource ...
return resource
}
|> AsyncResult.teeError (fun e -> // add resource error to the active trace
ctx.HttpContext
|> Trace.Http.active
|> Trace.addError (TracedError.ofError e)
|> ignore
)
|> parser.ForAsyncRes
)
.AfterCreate(fun ctx resource ->
let postOperationTrace = Trace.Http.active ctx.HttpContext // retrieve current active trace
use _ = "After Create" |> Trace.ChildOf.start postOperationTrace.Trace // trace after persist operation as another child of the active trace
// ... persist resource ...
resource
)- Increment version in
JsonApi.fsproj - Update
CHANGELOG.md - Commit new version and tag it
./build.sh build./build.sh -t tests