package sihl
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=bfa7bde9af02bb83d5ca39d54797b05b43317f033d93d24ca86ca42ff8ef83a1
sha512=6bb8727f65116e8042aa1fb77b3c14851ce5238f7b412adadf0f8e5b52d5310e8f06056c96bf76a82ffd7096753f49b2b0482f41e18ee1ca94310b874fe81bf9
doc/sihl.core/Core/Ctx/index.html
Module Core.Ctx
Source
The service request context is a key value store that can be used to pass arbitrary values from one service to another within the same request.
Key
The key of a value that can be stored in the context. The type of the key has to be indicated explicitly.
create_key ()
creates a key that can be used to store and retrieve values. The type needs to be indicated explicitly.
Example
let string_key: string = Sihl.Core.Ctx.create_key () in
let int_key: int = Sihl.Core.Ctx.create_key () in
let foo_key: Foo.t = Sihl.Core.Ctx.create_key ()
Map
The service request context is a heterogeneous map that can store values of different types. It is typically used to pass values to services that are either 1) only valid in the context of a service request or 2) whose types are hidden so that different service implementations of the same interface can take different values.
add key ctx
adds a value for the key
. If there is a value stored with the key it will be silently replaced.
remove key ctx
returns the context with the removed value behind the key
.