hyperlocal

Build Status

hyper client and server bindings for unix domain sockets

Hyper is a rock solid rustlang HTTP client and server tool kit. Unix domain sockets provide a mechanism for host-local interprocess communication. Hyperlocal builds on and complements hyper's interfaces for building unix domain socket HTTP clients and servers.

This is useful for providing simple HTTP interfaces for your Unix daemons in cases where you want to limit access to the current host, in which case, opening and exposing tcp ports is not needed. Examples of unix daemons that provide this kind of host local interface include, docker, a process container manager.

api docs

Find them here

install

tbd

usage

servers

A typical server can be build with hyperlocal::UnixSocketServer

```rust extern crate hyper; extern crate hyperlocal;

use hyper::server::{Request, Response}; use hyperlocal::UnixSocketServer;

fn main() { let path = "test.sock"; let server = UnixSocketServer::new(path).unwrap(); server.handle(|_: Request, res: Response| { let _ = res.send(b"It's a Unix system. I know this."); }).unwrap(); println!("listening @ {}", path); } ```

clients

You can communicate over HTTP with unix domain socket servers using hyper's Client interface. Configure your hyper client using Client::with_connector(UnixSocketConnector).

Hyper's client interface makes it easy to issue typical HTTP methods like GET, POST, DELETE with factory methods, get, post, delete, ect. These require something that can be tranformed into a Url. Since unix domain sockets don't hosts and ports, a simple string won't do. Instead use DomainUrl which wraps the path to the domain socket and the uri path and query string.

```rust extern crate hyper; extern crate hyperlocal;

use hyper::Client; use hyperlocal::{DomainUrl, UnixSocketConnector};

fn main() { let path = "test.sock"; let client = Client::with_connector(UnixSocketConnector); let mut res = client.get(DomainUrl::new(path, "/")).send().unwrap(); std::io::copy(&mut res, &mut std::io::stdout()).unwrap(); } ```

Doug Tangren (softprops) 2015