package sihl

  1. Overview
  2. Docs
The modular functional web framework

Install

Dune Dependency

Authors

Maintainers

Sources

sihl-queue-0.1.8.tbz
sha256=e77ffae26dac04e446ff07854de68a03edfd05031b5cb0dbcb6dc4a96e2d1c8e
sha512=7682c55136dbb8c68517ccd2c157a3556d966cb8565d15cf21ab270f92ea7e9ee5d3ac1479ba2e34a80f3052ca5dd1a74e964a8764c2164e3e71e9048fcdf51b

doc/sihl.core/Sihl_core/Ctx/index.html

Module Sihl_core.CtxSource

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

Sourcetype 'a key

The key of a value that can be stored in the context. The type of the key has to be indicated explicitly.

Sourceval create_key : unit -> 'a key

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

Sourcetype t

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.

Sourceval add : 'a key -> 'a -> t -> t

add key ctx adds a value for the key. If there is a value stored with the key it will be silently replaced.

Sourceval find : 'a key -> t -> 'a option

find key ctx returns the stored value.

Sourceval remove : 'a key -> t -> t

remove key ctx returns the context with the removed value behind the key.

Sourceval id : t -> string

id ctx returns the id of the context ctx. The ids of the currently active and used contexts are unique.

Sourceval sexp_of_t : t -> Sexplib0.Sexp.t

sexp_of_t t converts the context t to an s-expression

Sourceval create : ?id:string -> unit -> t

create ?id returns a context with id, if no id is provided one is randomly generated.

OCaml

Innovation. Community. Security.