torus-http

Crates.iotorus-http
lib.rstorus-http
version0.2.8
created_at2025-12-31 00:29:38.135679+00
updated_at2026-01-02 22:55:39.514168+00
descriptionToy RUSttp - aka Torus is a toy project synchronous http server library written with 0 dependencies
homepage
repositoryhttps://github.com/AfkaraLP/torus-http
max_upload_size
id2013675
size40,034
AfkaraLP (AfkaraLP)

documentation

https://docs.rs/torus-http

README

TOy RUSttp

TORUS is a small, synchronous HTTP server written in Rust (by the way).

Built as a learning project and a place to experiment with low-level HTTP handling. Security is minimal, correctness is good enough, and polish is not the point.

Do not deploy this on the public internet unless you enjoy consequences.

Has nice DX though...

Roadmap

  • Basic static routes
  • Dynamic routes
  • State management
  • Fewer bad ideas (unlikely)

Non-Goals

  • Be good
  • Be fast
  • Be secure
  • Brew coffee

Motivation

This project exists to better understand how HTTP servers work under the hood and to write flexible but intuitive Rust APIs

Example usage:

use torus_http::prelude::*;

fn main() {
    let server: HttpServer = HttpServer::new()
        .get("/", hello_world)
        .route(
            "/hello",
            HttpMethod::Other("custom".into()),
            |_| "hello from a custom method",
        )
        .add_middleware(|req| {
            println!("got request: {req:#?}");
            req
        });

    server
        .listen(("127.0.0.1", 8080))
        .expect("Failed listening...");
}

pub fn hello_world(req: Request) -> impl Response {
    HttpResponse::new()
        .set_body(format!(
            "<h1>hey there from torus!</h1><p>this is a test, your request is: {req:#?}</p>",
        ))
        .insert_header("Content-Type", "text/html")
}
Commit count: 0

cargo fmt