use std::{error::Error, fs, path::Path}; use hyper::{ service::{make_service_fn, service_fn}, Body, Response, Server, }; use hyperlocal::UnixServerExt; const PHRASE: &'static str = "It's a Unix system. I know this."; #[tokio::main] async fn main() -> Result<(), Box> { let path = Path::new("/tmp/hyperlocal.sock"); if path.exists() { fs::remove_file(path)?; } let make_service = make_service_fn(|_| async { Ok::<_, hyper::Error>(service_fn(|_req| async { Ok::<_, hyper::Error>(Response::new(Body::from(PHRASE))) })) }); Server::bind_unix(path)?.serve(make_service).await?; Ok(()) }