โ† Writing

๐ŸŒ std web_server

2024-12-10 rust ยท sync ยท project


Minimal yet functional multi-threaded web server implemented entirely using the Rust standard library. No external dependencies โ€” just pure std.


๐Ÿ“š GitHub Repository Rust Version

This project demonstrates how to build a basic but concurrent HTTP server by leveraging only the Rust Standard Library.
It serves as a deep dive into Rustโ€™s core capabilities around file I/O, networking, threading, and concurrency.

An excellent hands-on learning example for:


๐Ÿ›  Tech Stack โ€“ std Only

The server is powered by a thread pool and handles each TCP connection asynchronously using:


โœจ Features

  1. Multi-threaded request handling

    • Built-in thread pool to handle requests concurrently.
  2. Graceful connection handling

    • Supports reading HTTP headers via BufReader and routing based on request paths.
  3. Static file serving

    • Can serve .html files directly from the filesystem.
  4. Clean shutdown mechanism

    • Implements graceful shutdown via message passing.
  5. Zero dependencies

    • Uses only what std offers โ€” perfect for understanding how things work under the hood.

๐Ÿ“‚ Project Structure


๐Ÿงช Example Usage

cargo run

Then open your browser and go to: http://localhost:7878

To simulate a delayed response:


๐Ÿง  Educational Value

This project mirrors the concepts from โ€œThe Rust Programming Languageโ€ book (Chapter 20), but it goes further with:

Use it to:


๐Ÿ“„ License

This project is licensed under the MIT License โ€” feel free to build on it, fork it, or turn it into something bigger.