Skip to content

Commit

Permalink
Don't require a SocketAddr to make a SelfRequestOrigin
Browse files Browse the repository at this point in the history
This was forcing consumers who only had a DNS authority to resolve
to an IP address ahead of time instead of just passing the authority
along.

Signed-off-by: Ryan Levick <[email protected]>
  • Loading branch information
rylev committed Sep 12, 2024
1 parent 13d6299 commit a34c8a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions crates/factor-outbound-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod wasi;
pub mod wasi_2023_10_18;
pub mod wasi_2023_11_10;

use std::{net::SocketAddr, sync::Arc};
use std::sync::Arc;

use anyhow::Context;
use http::{
Expand Down Expand Up @@ -138,13 +138,12 @@ pub struct SelfRequestOrigin {
}

impl SelfRequestOrigin {
pub fn create(scheme: Scheme, addr: &SocketAddr) -> anyhow::Result<Self> {
pub fn create(scheme: Scheme, auth: &str) -> anyhow::Result<Self> {
Ok(SelfRequestOrigin {
scheme,
authority: addr
.to_string()
authority: auth
.parse()
.with_context(|| format!("address '{addr}' is not a valid authority"))?,
.with_context(|| format!("address '{auth}' is not a valid authority"))?,
})
}

Expand Down
2 changes: 1 addition & 1 deletion crates/trigger-http/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl<F: RuntimeFactors> HttpServer<F> {
.context(
"The wasi HTTP trigger was configured without the required wasi outbound http support",
)?;
let origin = SelfRequestOrigin::create(server_scheme, &self.listen_addr)?;
let origin = SelfRequestOrigin::create(server_scheme, &self.listen_addr.to_string())?;
outbound_http.set_self_request_origin(origin);
outbound_http.set_request_interceptor(OutboundHttpInterceptor::new(self.clone()))?;

Expand Down

0 comments on commit a34c8a3

Please sign in to comment.