Open
Description
The current server API is callback-based, where Service
is called whenever a request is received. Some applications need to invert it such that they take a request only when they are ready. This proposes creating a utility in hyper-util that would allow usage similar to this:
// naming is hard
let (svc, rx) = hyper_util::server::puller();
let conn = Http::new().serve_connection(socket, svc);
tokio::spawn(conn);
// pull off requests
while let Some((req, tx)) = rx.next().await? {
println!("{:?}", req);
tx.respond(Response::new(Empty::new());
}