Skip to content

Document that the client/server features are now opt-in #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ required-features = ["server", "hyper/runtime"]
[[test]]
name = "server_client"
required-features = ["client", "server", "hyper/runtime"]

[package.metadata.docs.rs]
all-features = true
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,21 @@ not needed. Examples of Unix daemons that provide this kind of host local interf

## Installation

Add the following to your `Cargo.toml` file
By default `hyperlocal` does not enable any [feature flags](https://doc.rust-lang.org/cargo/reference/features.html),
so you will need to enable the appropriate features for your use-case.

For server usage, add the following to your `Cargo.toml` file:

```toml
[dependencies]
hyperlocal = { version = "0.8", features = ["server"] }
```

Or for client usage:

```toml
[dependencies]
hyperlocal = "0.8"
hyperlocal = { version = "0.8", features = ["client"] }
```

## Usage
Expand Down Expand Up @@ -103,7 +113,7 @@ It's a Unix system. I know this.
Configure your `Hyper` client using `hyper::Client::builder()`.

Hyper's client interface makes it easy to send typical HTTP methods like `GET`, `POST`, `DELETE` with factory
methods, `get`, `post`, `delete`, etc. These require an argument that can be tranformed into a `hyper::Uri`.
methods, `get`, `post`, `delete`, etc. These require an argument that can be transformed into a `hyper::Uri`.

Since Unix domain sockets aren't represented with hostnames that resolve to ip addresses coupled with network ports,
your standard over the counter URL string won't do. Instead, use a `hyperlocal::Uri`, which represents both file path to the domain
Expand Down
8 changes: 4 additions & 4 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl tokio::io::AsyncRead for UnixStream {
}
}

/// the `[UnixConnector]` can be used to construct a `[hyper::Client]` which can
/// The [`UnixConnector`] can be used to construct a [`hyper::Client`] which can
/// speak to a unix domain socket.
///
/// # Example
Expand All @@ -70,8 +70,8 @@ impl tokio::io::AsyncRead for UnixStream {
/// ```
///
/// # Note
/// If you don't need access to the low-level `[hyper::Client]` builder
/// interface, consider using the `[UnixClientExt]` trait instead.
/// If you don't need access to the low-level [`hyper::Client`] builder
/// interface, consider using the [`UnixClientExt`] trait instead.
#[derive(Clone, Copy, Debug, Default)]
pub struct UnixConnector;

Expand Down Expand Up @@ -129,7 +129,7 @@ fn parse_socket_path(uri: &Uri) -> Result<PathBuf, io::Error> {
}
}

/// Extention trait for constructing a hyper HTTP client over a Unix domain
/// Extension trait for constructing a hyper HTTP client over a Unix domain
/// socket.
pub trait UnixClientExt {
/// Construct a client which speaks HTTP over a Unix domain socket
Expand Down
15 changes: 7 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@
//! `hyperlocal` provides [Hyper](http://github.com/hyperium/hyper) bindings
//! for [Unix domain sockets](https://github.com/tokio-rs/tokio/tree/master/tokio-net/src/uds/).
//!
//! See the [`UnixClientExt`] docs for
//! how to configure clients.
//! See the [`UnixClientExt`] docs for how to configure clients.
//!
//! See the
//! [`UnixServerExt`] docs for how to
//! configure servers.
//! See the [`UnixServerExt`] docs for how to configure servers.
//!
//! The [`UnixConnector`] can be used in the [`hyper::Client`] builder
//! interface, if required.
//!
//! # Features
//!
//! - Client- enables the client extension trait and connector. *Enabled by
//! default*.
//! By default `hyperlocal` does not enable any [feature flags](https://doc.rust-lang.org/cargo/reference/features.html).
//!
//! - Server- enables the server extension trait. *Enabled by default*.
//! The following features are available:
//!
//! - **`client`** — Enables the client extension trait and connector.
//! - **`server`** — Enables the server extension trait.

#[cfg(feature = "client")]
mod client;
Expand Down
2 changes: 1 addition & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) mod conn {
Ok(Self { listener })
}

/// Creates a new `SocketIncoming` from Tokio's `UnixListener`
/// Creates a new `SocketIncoming` from Tokio's [`UnixListener`].
///
/// ```rust,ignore
/// let socket = SocketIncoming::from_listener(unix_listener);
Expand Down
4 changes: 2 additions & 2 deletions src/uri.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use hyper::Uri as HyperUri;
use std::path::Path;

/// A convenience type that can be used to construct Unix Domain Socket URIs
/// A convenience type that can be used to construct Unix Domain Socket URIs.
///
/// This type implements `Into<hyper::Uri>`.
///
Expand All @@ -18,7 +18,7 @@ pub struct Uri {
}

impl Uri {
/// Create a new `[Uri]` from a socket address and a path
/// Create a new [`Uri`] from a socket address and a path.
///
/// # Panics
/// Will panic if path is not absolute and/or a malformed path string.
Expand Down