proxy-wasm-rust-sdk
proxy-wasm-rust-sdk copied to clipboard
get_property and set_property not working in Network filter
I have a wasm network plugin where I want to read a property that contains the value of an http header. I need this header so that I can know who belongs to a given stream.
The header value can be found in an http wasm filter easily like so (I get the actual api key back)
impl HttpContext for HttpHeaders {
fn on_http_response_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action {
let api_key = self
.get_property(vec!["metadata", "filter_metadata", "envoy.lb", "api-key"])
.map_or(Ok("no value set".to_string()), String::from_utf8)
.unwrap_or("couldn't covert".to_string());
proxy_wasm::hostcalls::log(
LogLevel::Info,
format!("on_http_response_headers: {:?}", api_key).as_str(),
);
Action::Continue
}
}
But if I put the same code in a network filter, I always get back "no value set"
impl StreamContext for MeterTcp {
fn on_upstream_data(&mut self, _data_size: usize, _end_of_stream: bool) -> Action {
let api_key = self
.get_property(vec!["metadata", "filter_metadata", "envoy.lb", "api-key"])
.map_or(Ok("no value set".to_string()), String::from_utf8)
.unwrap_or("couldn't covert".to_string());
proxy_wasm::hostcalls::log(
LogLevel::Info,
format!("on_upstream_data: {:?}", api_key).as_str(),
);
Action::Continue
}
}