Skip to main content

serve

Function serve 

Source
pub async fn serve(
    state: AppState,
    addr: SocketAddr,
) -> Result<(SocketAddr, impl Future<Output = Result<()>>)>
Expand description

Bind and serve. Returns the bound address, which matters when the caller asked for port 0.

Creates the unique indexes before binding. That used to live in the binary, which meant an embedder got a server whose _User collection accepted duplicate usernames: the write succeeded, no error reached the client, and the collision only surfaced later as two accounts answering to one name. Index creation is part of boot upstream too, so doing it here matches rather than extends. A failure is fatal for the same reason it is fatal upstream.

Served with connect info, because masterKeyIps filters on the connection’s peer address and there is nowhere else to get it. Without it the two privileged keys are refused outright.