Skip to content

Commit

Permalink
Merge pull request #2823 from fermyon/no-socket-addr-self-origin
Browse files Browse the repository at this point in the history
Don't require a `SocketAddr` to make a `SelfRequestOrigin`
  • Loading branch information
rylev committed Sep 12, 2024
2 parents 13d6299 + a34c8a3 commit 30f2e1e
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 30f2e1e

Please sign in to comment.