Skip to content

Commit

Permalink
feat: add local address getter to server builder
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkarw committed Jul 27, 2023
1 parent d77c259 commit 42d6db7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,14 @@ impl<E> Builder<AddrIncoming, E> {
self.incoming.set_sleep_on_errors(val);
self
}

/// Returns the local address that the server will be bound to.
///
/// This might be useful when knowing the address is required before calling `Builder::serve`,
/// but the address is not otherwise available (for e.g. when binding to port 0).
pub fn local_addr(&self) -> SocketAddr {
self.incoming.local_addr()
}
}

// Used by `Server` to optionally watch a `Connection` future.
Expand Down

0 comments on commit 42d6db7

Please sign in to comment.