#include <hook.hpp>
|
| | HookContext ()=default |
| |
| HookContext & | Set (std::string key, std::shared_ptr< std::any > value) |
| |
| std::optional< std::shared_ptr< std::any > > | Get (std::string const &key) const |
| |
| bool | Has (std::string const &key) const |
| |
HookContext allows passing arbitrary data from the caller through to hooks.
Example use case:
ctx.Set("otel_span_parent", std::make_shared<std::any>(span_context));
client.BoolVariation(context, "flag-key", false, ctx);
auto span_parent = hook_context.Get("otel_span_parent");
◆ HookContext()
| launchdarkly::server_side::hooks::HookContext::HookContext |
( |
| ) |
|
|
default |
◆ Get()
| std::optional< std::shared_ptr< std::any > > launchdarkly::server_side::hooks::HookContext::Get |
( |
std::string const & |
key | ) |
const |
Retrieves a value from the context.
- Parameters
-
- Returns
- The shared_ptr if present, or std::nullopt if not found.
◆ Has()
| bool launchdarkly::server_side::hooks::HookContext::Has |
( |
std::string const & |
key | ) |
const |
Checks if a key exists in the context.
- Parameters
-
- Returns
- True if the key exists, false otherwise.
◆ Set()
| HookContext & launchdarkly::server_side::hooks::HookContext::Set |
( |
std::string |
key, |
|
|
std::shared_ptr< std::any > |
value |
|
) |
| |
Sets a value in the context.
- Parameters
-
| key | The key to set. |
| value | The shared_ptr to any type to associate with the key. |
- Returns
- Reference to this context for chaining.
The documentation for this class was generated from the following files:
- include/launchdarkly/server_side/hooks/hook.hpp
- src/hooks/hook.cpp