Skip to content

Commit

Permalink
Make webhook endpoint an env-var
Browse files Browse the repository at this point in the history
  • Loading branch information
mwylde committed Jan 16, 2024
1 parent b0fc29f commit 71eee9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions arroyo-connectors/src/webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct WebhookConnector {}
impl WebhookConnector {
fn construct_test_request(client: &Client, config: &WebhookTable) -> anyhow::Result<Request> {
let req = client
.post(&config.endpoint)
.post(&config.endpoint.sub_env_vars()?)
// TODO: use the schema to construct a correctly-formatted message
.body(
serde_json::to_string(&json! {{
Expand All @@ -53,7 +53,7 @@ impl WebhookConnector {
.map(|s| s.sub_env_vars())
.transpose()?;

let client = construct_http_client(&config.endpoint, headers)?;
let client = construct_http_client(&config.endpoint.sub_env_vars()?, headers)?;
let req = Self::construct_test_request(&client, config)?;

tx.send(Ok(Event::default()
Expand Down Expand Up @@ -141,7 +141,7 @@ impl Connector for WebhookConnector {
table: Self::TableT,
schema: Option<&ConnectionSchema>,
) -> anyhow::Result<crate::Connection> {
let description = format!("WebhookSource<{}>", table.endpoint);
let description = format!("WebhookSink<{}>", table.endpoint.sub_env_vars()?);

let schema = schema
.map(|s| s.to_owned())
Expand Down Expand Up @@ -184,10 +184,13 @@ impl Connector for WebhookConnector {

let headers = options.remove("headers").map(|s| VarStr::new(s));

let table = WebhookTable { endpoint, headers };
let table = WebhookTable {
endpoint: VarStr::new(endpoint),
headers,
};

let client = construct_http_client(
&table.endpoint,
&table.endpoint.sub_env_vars()?,
table
.headers
.as_ref()
Expand Down
2 changes: 1 addition & 1 deletion arroyo-worker/src/connectors/webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ where
.collect();

Self {
url: Arc::new(table.endpoint),
url: Arc::new(table.endpoint.sub_env_vars().unwrap()),
client: reqwest::ClientBuilder::new()
.default_headers(headers)
.timeout(Duration::from_secs(5))
Expand Down
2 changes: 1 addition & 1 deletion connector-schemas/webhook/table.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"examples": [
"https://yourdomain.com/api/v1/webhooks"
],
"format": "uri"
"format": "var-str"
},
"headers": {
"title": "Headers",
Expand Down

0 comments on commit 71eee9a

Please sign in to comment.