waygate

Crates.iowaygate
lib.rswaygate
version0.1.0
created_at2025-12-03 07:33:45.916856+00
updated_at2025-12-03 07:33:45.916856+00
descriptionA modern HTTP client for Rust focusing on reliability, streaming, and extensibility.
homepage
repository
max_upload_size
id1963513
size41,307
quefep (M1tsumi)

documentation

README

waygate

waygate is a modern HTTP client for Rust. It focuses on predictable behaviour, a clean async API, and a design that can grow with services, CLIs, and libraries.

This repository currently contains an early 0.1.0 release of the library.

Status

The 0.1.0 release is intentionally small and focused:

  • Core client and HTTP types are defined.
  • A generic client type can be backed by different HTTP implementations.
  • A mock backend is available for fast, deterministic tests.
  • A hyper-based backend is available for real HTTP/1.1 and HTTP/2 traffic on Tokio.

Streaming bodies and more advanced configuration options are planned but not yet implemented in this release.

Features

  • Async client built on top of Tokio and hyper.
  • Backend abstraction so the same client API can be used with different HTTP stacks.
  • Mock client for unit and integration tests that do not need real network calls.
  • Hyper-backed client for real HTTP requests.
  • Simple configuration structure for basic timeouts and redirect limits.
  • Unified error type with clear variants for configuration and transport problems.

Installation

Add the crate to your Cargo.toml:

[dependencies]
waygate = "0.1.0"

Then import it in your code:

use waygate::HyperClient;

Quickstart

The example below performs a simple GET request using the hyper-backed client.

use http::Uri;
use waygate::HyperClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = HyperClient::new();

    let uri: Uri = "https://example.com".parse()?;
    let response = client.get(uri).await?;

    println!("Status: {}", response.status);
    println!("Body: {}", String::from_utf8_lossy(&response.body));

    Ok(())
}

For tests or local development, you can use the mock client:

use http::{Method, Uri};
use waygate::{MockClient, request::Request};

#[tokio::test]
async fn example_with_mock_client() {
    let client = MockClient::new();
    let uri: Uri = "http://example.test".parse().unwrap();
    let request = Request::new(Method::GET, uri);

    let response = client.send(request).await.unwrap();
    assert_eq!(response.status.as_u16(), 501);
}

Configuration

The client exposes a simple configuration structure that can be adjusted as needed:

use std::time::Duration;
use http::Uri;
use waygate::HyperClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = HyperClient::new();
    client.config_mut().request_timeout = Some(Duration::from_secs(5));

    let uri: Uri = "https://example.com".parse()?;
    let _response = client.get(uri).await?;

    Ok(())
}

As the library evolves, this configuration will grow to cover more advanced behaviour such as retry policies and redirect handling.

Roadmap

Planned areas of improvement include:

  • Streaming request and response bodies.
  • Richer configuration (retries, redirects, connection pooling controls).
  • Additional backend implementations.
  • More examples and stronger documentation.

For a more detailed view of the direction and milestones, see plan.md in the repository root.

License

This project is distributed under the terms of the license found in the LICENSE file.

Commit count: 0

cargo fmt