Skip to content
 
 

Latest commit

 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kokoro (Async HTTP Server Practice in Rust)

This is a simple asynchronous HTTP server built in Rust using tokio. It’s a personal project for learning and practicing how to implement basic HTTP server functionality from scratch.

Features

  • ✅ Async TCP server with tokio
  • ✅ Simple routing with path parameters (e.g., /hello/:name)
  • ✅ Request parsing (method, path, headers, query string)
  • ✅ Response builder with status, headers, and body
  • ✅ Prebuilt response types: Html, Json, Text

TODO / Planned Improvements

  • Add middleware support (e.g., logging)
  • Serve static files
  • Parse request body (form data)
  • Way to share state between requests (e.g., state management)

Example

use kokoro::{
    request::Request,
    response::{Html},
    router::Router,
    serve,
};
use tokio::net::TcpListener;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let router = Router::new()
        .get("/", |_req| async {
            Html("<h1>Hello, World!</h1>")
        })
        .get("/hello/:name", |req: Request| async move {
            let name = req.param("name").unwrap_or("Guest");
            Html(format!("<h1>Hello, {name}!</h1>"))
        });

    let listener = TcpListener::bind("127.0.0.1:8080").await?;
    serve(listener, router).await
}

Notes

This is not a production-ready framework — just a hands-on way to explore low-level async Rust and how web servers work.

License

MIT

About

This is a simple asynchronous HTTP server built in Rust using tokio. It’s a personal project for learning and practicing how to implement basic HTTP server functionality from scratch.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages