pub trait UnixServerExt {
// Required method
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::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?;
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.