diff --git a/src/data/cel.rs b/src/data/cel.rs index 0f71ce1..83f8167 100644 --- a/src/data/cel.rs +++ b/src/data/cel.rs @@ -5,6 +5,7 @@ use cel_interpreter::objects::{Key, Map, ValueType}; use cel_interpreter::{Context, ExecutionError, ResolveResult, Value}; use cel_parser::{parse, Expression as CelExpression, Member, ParseError}; use chrono::{DateTime, FixedOffset}; +use log::debug; use proxy_wasm::types::{Bytes, Status}; use serde_json::Value as JsonValue; use std::collections::hash_map::Entry; @@ -441,6 +442,22 @@ fn properties<'e>(exp: &'e CelExpression, all: &mut Vec>, path: &mu } } +#[allow(dead_code)] +pub fn debug_all_well_known_attributes() { + let attributes = new_well_known_attribute_map(); + attributes.iter().for_each(|(key, value_type)| { + match proxy_wasm::hostcalls::get_property(key.tokens()) { + Ok(opt_bytes) => match opt_bytes { + None => debug!("{:#?}({}): None", key, value_type), + Some(bytes) => debug!("{:#?}({}): {:?}", key, value_type, bytes), + }, + Err(err) => { + debug!("{:#?}({}): (err) {:?}", key, value_type, err) + } + } + }) +} + pub mod data { use crate::data::cel::Attribute; use cel_interpreter::objects::{Key, Map}; diff --git a/src/data/mod.rs b/src/data/mod.rs index 0e1cc10..004ece6 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -11,3 +11,5 @@ pub use cel::Predicate; pub use property::get_property; pub use property::Path as PropertyPath; + +// pub use cel::debug_all_well_known_attributes; diff --git a/src/filter/http_context.rs b/src/filter/http_context.rs index e365ccd..e7e407f 100644 --- a/src/filter/http_context.rs +++ b/src/filter/http_context.rs @@ -7,6 +7,7 @@ use proxy_wasm::traits::{Context, HttpContext}; use proxy_wasm::types::Action; use std::cell::RefCell; use std::rc::Rc; +// use crate::data; pub struct Filter { pub context_id: u32, @@ -94,6 +95,9 @@ impl HttpContext for Filter { fn on_http_request_headers(&mut self, _: usize, _: bool) -> Action { debug!("#{} on_http_request_headers", self.context_id); + // uncomment to debug log all well known attributes + // data::debug_all_well_known_attributes(); + match self .config .index