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
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context from which to retrieve the value. This context typically holds request-scoped values. |
| key | Key | The key used to identify the desired value within the context. This key should be unique within the context's value store. |
Returns
| Type | Description |
|---|---|
string | The 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. |