Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add local addr getter to server builder #3278

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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