Skip to main content

spawn

Function spawn 

Source
pub async fn spawn<F>(addr: &str, handler: F) -> Result<HttpServer>
where F: FnMut(HttpRequest) -> HttpResponse + Send + 'static,
Expand description

Bind addr, spawn the accept loop onto the tokio runtime, and return a handle carrying the bound port. For tests and embedders (the handler is Send). Always the TOKIO engine: the handle’s drop-aborts contract needs a task, not OS threads — engine selection belongs to the blocking serve entry (the io_uring engine’s own handle is engine_uring::UringServer).