HTTPageboy
Minimal HTTP server package for handling request/response transmission. Focuses only on transporting a well formed HTTP message; does not process or decide how the server behaves. Aspires to become runtime-agnostic, with minimal, solid, and flexible dependencies.
Example
The core logic resides in src/lib.rs.
See it working out of the box on this video
The following example is executable. Run cargo run to see the available variants and navigate to http://127.0.0.1:7878 in your browser.
A basic server setup (select a runtime feature when running, e.g. cargo run --features async_tokio):
use ;
/// Minimal async handler: waits 100ms and replies "ok"
async
async
Testing
Test helpers live in httpageboy::test_utils and work the same for sync and async runtimes:
setup_test_server(server_url, factory)starts a server once per URL and marks it active (passNoneto reuse the default127.0.0.1:0and let the OS pick a port).run_test(request, expected, target_url)opens a TCP connection to the active server (or the URL you pass), writes a raw HTTP payload, and asserts the response contains the expected bytes.
Async tokio example mirroring the current helpers:
use ;
use ;
async
async
async
CORS
Servers now ship with a permissive CORS policy by default (allow all origins, methods, and common headers). You can tighten it after constructing the server:
let mut server = new.await.unwrap;
server.set_cors_str;
// or build it directly:
// server.set_cors(CorsPolicy::from_config_str("origin=http://localhost:3000"));
Preflights (OPTIONS) are answered automatically using the active policy.
Comandos:
Examples
Additional examples can be found within the tests.
License
Copyright (c) 2025 fahedsl. This project is licensed under the MIT License.