Request Context

The ctx module reads request-scoped values propagated through function calls or process operations. This page is an API reference; the snippets show individual calls inside an executable Lua entry.

Loading

local ctx = require("ctx")

Context Access

Get a Value

local value, err = ctx.get("key")
Parameter Type Description
key string Context key

Returns: any, error

Get All Values

local values, err = ctx.all()

Returns: table, error

ctx.all() returns an empty table when an execution context is present but has no request values. A missing execution context returns nil, errors.INTERNAL.

Errors

Condition Kind Retryable
Empty key errors.INVALID no
Key not found errors.NOT_FOUND no
No execution context available errors.INTERNAL no

See Error Handling for working with errors.