Skip to content

Commit

Permalink
Remove unnecessary package
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-cattermole committed Mar 25, 2024
1 parent b2358cc commit 86aa753
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 36 deletions.
27 changes: 0 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
17 changes: 10 additions & 7 deletions src/filter/http_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,36 @@ 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;
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,
Baggage,
}

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",
}
}
}
Expand Down Expand Up @@ -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 => (),
Expand Down

0 comments on commit 86aa753

Please sign in to comment.