Skip to content

Commit

Permalink
feat(server): add Builder::local_addr() (#3278)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkarw committed Aug 7, 2023
1 parent 45aa624 commit d342c2c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/server/server.rs
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 d342c2c

Please sign in to comment.