A lightweight, asynchronous HTTP server written in Rust as a learning project. This server demonstrates concurrent connection handling using Tokio and includes custom request handling capabilities.
- Asynchronous I/O: Built with Tokio for efficient concurrent connection handling
- Connection Limiting: Supports up to 10,000 concurrent connections
- Cross-Platform: Works on both Windows and Unix-based systems
- Modular Architecture: Organized into separate libraries for request handling and utilities
- Graceful Shutdown: Interactive console control with graceful server termination
simple_http_server/
├── src/
│ ├── main.rs # Entry point and server initialization
│ └── lib.rs # Core server logic
├── libs/
│ ├── request_handler/ # HTTP request handling library
│ └── utils/ # Utility functions (thread pool, logging)
├── resources/ # HTML files and static resources
│ ├── hello.html
│ ├── 404.html
│ └── debug.html
├── tests/ # Integration tests
└── Cargo.toml # Project configuration
- Rust 1.70 or higher
- Cargo (comes with Rust)
- Clone the repository:
git clone https://github.com/yourusername/simple_http_server.git
cd simple_http_server- Build the project:
cargo build --releaseStart the server with:
cargo runThe server will start listening on http://127.0.0.1:7877 by default.
Type q in the terminal and press Enter to gracefully stop the server.
Run the test suite:
cargo test --workspaceThe server binds to 127.0.0.1:7877 by default. To change the address or port, modify the following line in src/main.rs:
run_server("127.0.0.1:7877", handle_input()).await?;- tokio (1.49.0): Asynchronous runtime with full features
- anyhow (1.0.100): Error handling
- request_handler: Custom HTTP request handler (local library)
- utils: Utility functions (local library)
- Unix:
libc(0.2) - Windows:
windows-sys(0.52)
cargo buildcargo runcargo doc --openThis project uses Cargo workspaces with the following members:
libs/request_handler: HTTP request parsing and handlinglibs/utils: Shared utilities (thread pool, scope time logger)
This project is licensed under the MIT License.
This project was created as a Rust learning exercise to explore:
- Asynchronous programming with Tokio
- TCP socket handling
- HTTP protocol basics
- Rust's module system and workspace organization
- Concurrent programming patterns
- Error handling with
anyhow
Built as part of learning Rust programming language. Special thanks to the Rust community and the excellent Tokio documentation.
As this is a learning project, contributions, suggestions, and feedback are welcome! Feel free to:
- Open issues for bugs or feature requests
- Submit pull requests
- Share your improvements or learning experiences
Note: This is a learning project and not intended for production use. For production HTTP servers, consider using battle-tested solutions like Actix-web, Rocket, or Axum.