OxL Reference

fn withMeta

Runs body with extra request metadata: every rpc it calls (and every task it spawns) carries meta in ctx.meta. The user id travels as x-oxl-user (D-2905).

Example:

oxl✓ checked in CI
use std.rpc { withMeta }

fn main() io {
  var meta: Map<str, str> = Map.new()
  meta.insert("x-request-id", "r-1")
  let n = withMeta(meta) { 40 + 2 }
  print("{n}")
}
Output
42
pub(api) fn withMeta<T, effect F>(meta: Map<str, str>, body: fn() -> T F) -> T  F

Thread safety. the metadata belongs to the calling task and the tasks it spawns inside `body`; other tasks do not see it.

Since. 1.0.0-beta

Parameters

NameType
metaMap<str, str>
bodyfn() -> T F

Returns

T F

Effects

none declared (pure unless the body says otherwise)

Defined in: std/rpc/rpc.oxl:280

See also