Skip to main content

Value

Retrieves a string value associated with a given key from the context. If the key is not found or the value is not a string, it returns an empty string.

def Value(
ctx: context.Context,
key: Key
) - > string

Retrieves a string value associated with a given key from the provided context. This function is used to safely extract string data that may have been stored in the context.

Parameters

NameTypeDescription
ctxcontext.ContextThe context from which to retrieve the value. This context typically holds request-scoped values.
keyKeyThe key used to identify the desired value within the context. This key should be unique within the context's value store.

Returns

TypeDescription
stringThe string value associated with the key in the context, or an empty string if the key is not found or the value is not a string.