mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-27 10:39:03 +02:00
Unix domain sockets (HttpServer::bind_uds) #92
This commit is contained in:
@ -78,6 +78,7 @@
|
||||
//! `c` compiler (default enabled)
|
||||
//! * `flate2-rust` - experimental rust based implementation for
|
||||
//! `gzip`, `deflate` compression.
|
||||
//! * `uds` - Unix domain support, enables `HttpServer::bind_uds()` method.
|
||||
//!
|
||||
#![allow(clippy::type_complexity, clippy::new_without_default)]
|
||||
|
||||
|
@ -434,6 +434,38 @@ where
|
||||
}
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
#[cfg(feature = "uds")]
|
||||
/// Start listening for incoming unix domain connections.
|
||||
///
|
||||
/// This method is available with `uds` feature.
|
||||
pub fn bind_uds<A>(mut self, addr: A) -> io::Result<Self>
|
||||
where
|
||||
A: AsRef<std::path::Path>,
|
||||
{
|
||||
let cfg = self.config.clone();
|
||||
let factory = self.factory.clone();
|
||||
self.sockets.push(Socket {
|
||||
scheme: "http",
|
||||
addr: net::SocketAddr::new(
|
||||
net::IpAddr::V4(net::Ipv4Addr::new(127, 0, 0, 1)),
|
||||
8080,
|
||||
),
|
||||
});
|
||||
|
||||
self.builder = self.builder.bind_uds(
|
||||
format!("actix-web-service-{:?}", addr.as_ref()),
|
||||
addr,
|
||||
move || {
|
||||
let c = cfg.lock();
|
||||
HttpService::build()
|
||||
.keep_alive(c.keep_alive)
|
||||
.client_timeout(c.client_timeout)
|
||||
.finish(factory())
|
||||
},
|
||||
)?;
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<F, I, S, B> HttpServer<F, I, S, B>
|
||||
|
Reference in New Issue
Block a user