Skip to content

Commit 3e8bd9a

Browse files
wip - permutive
1 parent 56920c9 commit 3e8bd9a

File tree

11 files changed

+140
-507
lines changed

11 files changed

+140
-507
lines changed

crates/common/src/error.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ pub enum TrustedServerError {
6161
#[display("Permutive SDK error: {message}")]
6262
PermutiveSdk { message: String },
6363

64-
/// Permutive API proxy error.
65-
#[display("Permutive API error: {message}")]
66-
PermutiveApi { message: String },
67-
6864
/// Proxy error.
6965
#[display("Proxy error: {message}")]
7066
Proxy { message: String },
@@ -108,7 +104,6 @@ impl IntoHttpResponse for TrustedServerError {
108104
Self::Prebid { .. } => StatusCode::BAD_GATEWAY,
109105
Self::Integration { .. } => StatusCode::BAD_GATEWAY,
110106
Self::PermutiveSdk { .. } => StatusCode::BAD_GATEWAY,
111-
Self::PermutiveApi { .. } => StatusCode::BAD_GATEWAY,
112107
Self::Proxy { .. } => StatusCode::BAD_GATEWAY,
113108
Self::SyntheticId { .. } => StatusCode::INTERNAL_SERVER_ERROR,
114109
Self::Template { .. } => StatusCode::INTERNAL_SERVER_ERROR,

crates/common/src/generic_proxy.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ pub async fn handle_generic_proxy(
6666
);
6767

6868
// Extract target path
69-
let target_path = mapping
70-
.extract_target_path(path)
71-
.ok_or_else(|| TrustedServerError::Proxy {
72-
message: format!(
73-
"Failed to extract target path from {} with prefix {}",
74-
path, mapping.prefix
75-
),
76-
})?;
69+
let target_path =
70+
mapping
71+
.extract_target_path(path)
72+
.ok_or_else(|| TrustedServerError::Proxy {
73+
message: format!(
74+
"Failed to extract target path from {} with prefix {}",
75+
path, mapping.prefix
76+
),
77+
})?;
7778

7879
// Build full target URL with query parameters
7980
let target_url = build_target_url(&mapping.target, target_path, &req)?;
@@ -95,11 +96,12 @@ pub async fn handle_generic_proxy(
9596
// Get backend and forward request
9697
let backend_name = ensure_backend_from_url(&mapping.target)?;
9798

98-
let target_response = target_req
99-
.send(backend_name)
100-
.change_context(TrustedServerError::Proxy {
101-
message: format!("Failed to forward request to {}", target_url),
102-
})?;
99+
let target_response =
100+
target_req
101+
.send(backend_name)
102+
.change_context(TrustedServerError::Proxy {
103+
message: format!("Failed to forward request to {}", target_url),
104+
})?;
103105

104106
log::info!(
105107
"Target responded with status: {}",
@@ -119,9 +121,7 @@ fn find_proxy_mapping<'a>(
119121
settings
120122
.proxy_mappings
121123
.iter()
122-
.find(|mapping| {
123-
mapping.matches_path(path) && mapping.supports_method(method.as_str())
124-
})
124+
.find(|mapping| mapping.matches_path(path) && mapping.supports_method(method.as_str()))
125125
.ok_or_else(|| {
126126
TrustedServerError::Proxy {
127127
message: format!(
@@ -252,10 +252,7 @@ mod tests {
252252
Some("/v2/projects")
253253
);
254254
assert_eq!(mapping.extract_target_path("/permutive/api"), Some(""));
255-
assert_eq!(
256-
mapping.extract_target_path("/permutive/api/"),
257-
Some("/")
258-
);
255+
assert_eq!(mapping.extract_target_path("/permutive/api/"), Some("/"));
259256
assert_eq!(mapping.extract_target_path("/other/path"), None);
260257
}
261258

crates/common/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ pub mod http_util;
3838
pub mod integrations;
3939
pub mod models;
4040
pub mod openrtb;
41-
pub mod permutive_proxy;
4241
pub mod permutive_sdk;
4342
pub mod prebid_proxy;
4443
pub mod proxy;

0 commit comments

Comments
 (0)