Skip to content

Commit

Permalink
Use contants for headers and explicitly lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-cattermole committed Mar 21, 2024
1 parent c37de84 commit b219de4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/filter/http_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ use std::time::Duration;
const RATELIMIT_SERVICE_NAME: &str = "envoy.service.ratelimit.v3.RateLimitService";
const RATELIMIT_METHOD_NAME: &str = "ShouldRateLimit";

// tracing headers
const TRACEPARENT_HEADER: &str = "traceparent";
const TRACESTATE_HEADER: &str = "tracestate";
const BAGGAGE_HEADER: &str = "baggage";

pub struct Filter {
pub context_id: u32,
pub config: Rc<FilterConfig>,
Expand Down Expand Up @@ -216,8 +221,8 @@ impl HttpContext for Filter {

let req_headers = self.get_http_request_headers();
for (header, value) in req_headers.iter() {
match header.as_str() {
"traceparent" | "tracestate" | "baggage" => {
match header.to_lowercase().as_str() {
TRACEPARENT_HEADER | TRACESTATE_HEADER | BAGGAGE_HEADER => {
self.tracing_headers.push((header.clone(), value.clone()))
}
_ => (),
Expand Down

0 comments on commit b219de4

Please sign in to comment.