Skip to content

Commit

Permalink
Stop using match to destructure single patterns.
Browse files Browse the repository at this point in the history
  • Loading branch information
sporkmonger committed Nov 26, 2024
1 parent 3e85196 commit fbd5c8f
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions crates/ext-processor/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,20 +537,17 @@ impl ProcessorContext {
};
// No current access to HTTP version information via Envoy external processor
request = request.method(method).uri(request_uri);
match &header_msg.headers {
Some(headers) => {
for header in &headers.headers {
// must not pass through Envoy pseudo headers here, http module treats them as invalid
if !header.key.starts_with(':') {
if !header.raw_value.is_empty() {
request = request.header(&header.key, header.raw_value.as_slice());
} else {
request = request.header(&header.key, header.value.as_str());
}
if let Some(headers) = &header_msg.headers {
for header in &headers.headers {
// must not pass through Envoy pseudo headers here, http module treats them as invalid
if !header.key.starts_with(':') {
if !header.raw_value.is_empty() {
request = request.header(&header.key, header.raw_value.as_slice());
} else {
request = request.header(&header.key, header.value.as_str());
}
}
}
None => {}
}

// TODO: remote IP should probably be received via an external attribute, but that doesn't seem to be currently supported by envoy?
Expand Down Expand Up @@ -596,21 +593,17 @@ impl ProcessorContext {
bytes::Bytes::new()
};
response = response.status(status).version(self.request.version());
match &header_msg.headers {
Some(headers) => {
for header in &headers.headers {
// must not pass through Envoy pseudo headers here, http module treats them as invalid
if !header.key.starts_with(':') {
if !header.raw_value.is_empty() {
response =
response.header(&header.key, header.raw_value.as_slice());
} else {
response = response.header(&header.key, header.value.as_str());
}
if let Some(headers) = &header_msg.headers {
for header in &headers.headers {
// must not pass through Envoy pseudo headers here, http module treats them as invalid
if !header.key.starts_with(':') {
if !header.raw_value.is_empty() {
response = response.header(&header.key, header.raw_value.as_slice());
} else {
response = response.header(&header.key, header.value.as_str());
}
}
}
None => {}
}
return Ok(response.body(response_chunk)?);
}
Expand Down

0 comments on commit fbd5c8f

Please sign in to comment.