[][src]Trait hyperlocal::UnixServerExt

pub trait UnixServerExt {
    pub fn bind_unix(
        path: impl AsRef<Path>
    ) -> Result<Builder<SocketIncoming>, Error>; }

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

pub fn bind_unix(
    path: impl AsRef<Path>
) -> Result<Builder<SocketIncoming>, Error>
[src]

Convenience method for constructing a Server listening on a Unix socket.

Loading content...

Implementations on Foreign Types

impl UnixServerExt for Server<SocketIncoming, ()>[src]

Loading content...

Implementors

Loading content...