httpageboy

Crates.iohttpageboy
lib.rshttpageboy
version1.0.12
created_at2024-11-04 05:41:52.036767+00
updated_at2025-09-24 11:54:00.350215+00
descriptionA lightweight library for handling raw HTTP request/response transmission. Good base for APIs. Supports both synchronous and asynchronous programming models.
homepagehttps://gitlab.com/numanope/libs/rs/http-server
repositoryhttps://gitlab.com/numanope/libs/rs/http-server
max_upload_size
id1434571
size145,539
fahedsl (fahedslx)

documentation

https://docs.rs/httpageboy

README

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:

use httpageboy::{Request, Response, Rt, Server, StatusCode}; // Rt is alias for ResponseType

fn main() {
  let serving_url: &str = "127.0.0.1:7878";
  let threads_number: u8 = 10;
  let mut server = Server::new(serving_url, threads_number, None).unwrap();
  server.add_route("/", Rt::GET, demo_get);
  server.add_files_source("res"); // this points to the /res folder in the project root
  server.run();
}

fn demo_get(_request: &Request) -> Response {
  Response {
    status: StatusCode::Ok.to_string(),
    content_type: String::new(),
    content: "<!DOCTYPE html><html><head>\
<meta charset=\"utf-8\">\
</head><body>🤓: Hi, this is Pageboy working.
<br>Do you like the <a href=\"/HTTPageboy.svg\">new icon</a>?</body></html>"
      .as_bytes()
      .to_vec(),
  }
}

Testing

For synchronous tests:

cargo test --features sync --test test_sync

For asynchronous tests:

cargo test --features async_tokio --test test_async_tokio
cargo test --features async_std --test test_async_std
// or
cargo test --features async_smol --test test_async_smol

Examples

Additional examples can be found within the tests.

License

Copyright (c) 2025 fahedsl. This project is licensed under the MIT License.

Commit count: 0

cargo fmt