Skip to content

Commit

Permalink
feat: support rewrite config after parse_rule_config invoked (aliba…
Browse files Browse the repository at this point in the history
  • Loading branch information
jizhuozhi authored Jun 28, 2023
1 parent 9fc2760 commit fc05a3b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions plugins/wasm-rust/src/rule_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ where
return self.global_config.as_ref();
}

pub fn rewrite_config(&mut self, rewrite: fn(config: &PluginConfig) -> PluginConfig) {
self.global_config = match self.global_config.as_ref() {
None => None,
Some(config) => Some(rewrite(config))
};

for rule_config in &mut self.rule_config {
rule_config.config = rewrite(&rule_config.config);
}
}

fn parse_route_match_config(config: &Value) -> HashSet<String> {
let empty_vec = Vec::new();
let keys = config[MATCH_ROUTE_KEY].as_array().unwrap_or(&empty_vec);
Expand Down

0 comments on commit fc05a3b

Please sign in to comment.