momento_functions_host/
web_extensions.rs

1//! Host interface extensions for Web Functions
2//!
3//! These interfaces don't do anything on other kinds of Functions.
4
5use momento_functions_wit::function_web::momento::functions::web_function_support;
6
7/// Returns the headers for the web function, if any are present.
8/// This consumes the headers and takes ownership of the value; multiple calls after will always
9/// yield `None`.
10pub fn headers() -> Vec<(String, String)> {
11    web_function_support::headers()
12        .into_iter()
13        .map(|web_function_support::Header { name, value }| (name, value))
14        .collect()
15}
16
17/// Returns the metadata within the caller's token, if present.
18/// This consumes the metadata and takes ownership of the value; multiple calls after will always
19/// yield `None`.
20pub fn token_metadata() -> Option<String> {
21    web_function_support::token_metadata()
22}