pub trait UnixServerExt {
fn bind_unix(
path: impl AsRef<Path>
) -> Result<Builder<SocketIncoming>, Error>;
}
Expand description
Extension trait for provisioning a hyper HTTP server over a Unix domain socket.
Example
use hyper::{Server, Body, Response, service::{make_service_fn, service_fn}};
use hyperlocal_with_windows::UnixServerExt;
let make_service = make_service_fn(|_| async {
Ok::<_, hyper::Error>(service_fn(|_req| async {
Ok::<_, hyper::Error>(Response::new(Body::from("It works!")))
}))
});
Server::bind_unix("/tmp/hyperlocal.sock")?.serve(make_service).await?;