pub async fn serve_with_addr(
addr: impl ToSocketAddrs,
dispatcher: impl Dispatcher,
) -> Result<SocketAddr, Error>๐Deprecated since 0.16.0:
it cannot be stopped: bind a Server, read local_addr(), and spawn serve_with_shutdown; removed no earlier than 0.17.0
Expand description
Starts an HTTP server on a background task and returns the bound
SocketAddr. Nothing can stop the task.
Binds before entering the accept loop, spawns it, and returns the actual
address (useful when binding to port 0). It runs on a Server under
ServeConfig::default().
Deprecated in 0.16.0 (ADR 0052), removed no earlier than 0.17.0: bind a
Server, read Server::local_addr, and keep the task that runs
Server::serve_with_shutdown.
ยงErrors
Returns std::io::Error if the TCP listener fails to bind.