diff --git a/Cargo.lock b/Cargo.lock index 4e882d88..1ff0afd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1324,12 +1324,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - [[package]] name = "ryu" version = "1.0.11" @@ -1466,25 +1460,6 @@ dependencies = [ "syn 1.0.99", ] -[[package]] -name = "strum" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" - -[[package]] -name = "strum_macros" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" -dependencies = [ - "heck 0.4.1", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.18", -] - [[package]] name = "syn" version = "1.0.99" @@ -1709,8 +1684,6 @@ dependencies = [ "serde", "serde_json", "serial_test", - "strum", - "strum_macros", "thiserror", ] diff --git a/Cargo.toml b/Cargo.toml index ed23b588..a06794c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,8 +24,6 @@ protobuf = { version = "2.27", features = ["with-serde"] } thiserror = "1.0" regex = "1" radix_trie = "0.2.1" -strum = "0.26.2" -strum_macros = "0.26.2" [dev-dependencies] proxy-wasm-test-framework = { git = "https://github.com/Kuadrant/wasm-test-framework.git", branch = "kuadrant" } diff --git a/src/filter/http_context.rs b/src/filter/http_context.rs index 0f884dc5..e7cf9503 100644 --- a/src/filter/http_context.rs +++ b/src/filter/http_context.rs @@ -6,6 +6,7 @@ use crate::envoy::{ RateLimitDescriptor, RateLimitDescriptor_Entry, RateLimitRequest, RateLimitResponse, RateLimitResponse_Code, }; +use crate::filter::http_context::TracingHeader::{Baggage, Traceparent, Tracestate}; use crate::utils::tokenize_with_escaping; use log::{debug, info, warn}; use protobuf::Message; @@ -13,14 +14,12 @@ use proxy_wasm::traits::{Context, HttpContext}; use proxy_wasm::types::{Action, Bytes}; use std::rc::Rc; use std::time::Duration; -use strum::IntoEnumIterator; -use strum_macros::EnumIter; const RATELIMIT_SERVICE_NAME: &str = "envoy.service.ratelimit.v3.RateLimitService"; const RATELIMIT_METHOD_NAME: &str = "ShouldRateLimit"; // tracing headers -#[derive(EnumIter)] +#[derive(Clone)] pub enum TracingHeader { Traceparent, Tracestate, @@ -28,11 +27,15 @@ pub enum TracingHeader { } impl TracingHeader { + fn all() -> [Self; 3] { + [Traceparent, Tracestate, Baggage] + } + fn as_str(&self) -> &'static str { match self { - TracingHeader::Traceparent => "traceparent", - TracingHeader::Tracestate => "tracestate", - TracingHeader::Baggage => "baggage", + Traceparent => "traceparent", + Tracestate => "tracestate", + Baggage => "baggage", } } } @@ -234,7 +237,7 @@ impl HttpContext for Filter { fn on_http_request_headers(&mut self, _: usize, _: bool) -> Action { info!("on_http_request_headers #{}", self.context_id); - for header in TracingHeader::iter() { + for header in TracingHeader::all() { match self.get_http_request_header_bytes(header.as_str()) { Some(value) => self.tracing_headers.push((header, value)), None => (),