Skip to content

Commit

Permalink
Merge pull request #33 from Kuadrant/fix
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
alexsnaps authored Mar 28, 2023
2 parents decf58c + e2d9e9e commit 0e931d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/filter/http_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const RATELIMIT_METHOD_NAME: &str = "ShouldRateLimit";
pub struct Filter {
pub context_id: u32,
pub config: Rc<FilterConfig>,
pub headers: Vec<(String, String)>,
pub response_headers_to_add: Vec<(String, String)>,
}

impl Filter {
Expand Down Expand Up @@ -307,7 +307,7 @@ impl HttpContext for Filter {
}

fn on_http_response_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action {
for (name, value) in &self.headers {
for (name, value) in &self.response_headers_to_add {
self.add_http_response_header(name, value);
}
Action::Continue
Expand Down Expand Up @@ -364,11 +364,12 @@ impl Context for Filter {
}
RateLimitResponse {
overall_code: RateLimitResponse_Code::OK,
response_headers_to_add: response_headers,
response_headers_to_add: additional_headers,
..
} => {
for header in response_headers {
self.headers.push((header.key, header.value));
for header in additional_headers {
self.response_headers_to_add
.push((header.key, header.value));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/filter/root_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl RootContext for FilterRoot {
Some(Box::new(Filter {
context_id,
config: Rc::clone(&self.config),
headers: Vec::default(),
response_headers_to_add: Vec::default(),
}))
}

Expand Down

0 comments on commit 0e931d8

Please sign in to comment.