Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 89 additions & 61 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,107 +1,135 @@
# 🍵 HteaPot HTTP Server
<h1 align="center">🍵 HTeaPot</h1>
<p align="center"><b>A blazing-fast, minimalist HTTP server library built with Rust</b></p>

[Spanish](docs/i8n/readme-es.md) | English
<p align="center">
<a href="https://crates.io/crates/hteapot"><img alt="Crates.io" src="https://img.shields.io/crates/v/hteapot.svg?style=flat-square"></a>
<a href="https://docs.rs/hteapot"><img alt="Documentation" src="https://img.shields.io/docsrs/hteapot?style=flat-square"></a>
<!-- <a href="https://github.com/Az107/HTeaPot/actions"><img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/Az107/HTeaPot/rust.yml?branch=main&style=flat-square"></a> -->
<a href="https://opensource.org/licenses/MIT"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square"></a>
<a href="https://github.com/Az107/HTeaPot" target="_blank"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/Az107/HTeaPot"></a>
</p>

Hteapot is a powerful, Rust-based HTTP server and library designed for high-performance web applications. Effortlessly serve static files and handle HTTP requests with resilience and speed.
<p align="center">
<a href="README.md">English</a> |
<a href="README.es.md">Español</a>
</p>

# Features

### 1. **Threaded Architecture**
Custom thread-based system, capable of handling around **70,000 requests per second**.
A high-performance, lightweight HTTP server and library built in Rust. HTeaPot is designed to deliver exceptional performance for modern web applications while maintaining a simple and intuitive API.

## Features

### 2. **Performance Under Load**
Steady performance under high concurrency
### Exceptional Performance
- **Threaded Architecture**: Powered by a custom-designed thread system that handles **70,000+ requests per second**
- **Consistent Under Load**: Maintains steady performance even under high concurrency scenarios
- **Resilient**: Achieves **near-perfect 100% success rate** for 200 OK responses during stress tests

### Versatile Functionality
- **Static File Serving**: Efficiently serve static assets with minimal configuration
- **Streaming Support**: Leverages chunked transfer encoding for large files and long-lived connections
- **Flexible API**: Use HTeaPot as a standalone server or as a library in your Rust applications

### 3. **Low Error Rate**
- Achieves a near **100% success rate for 200 OK responses** during stress tests, demonstrating strong resilience.
- Outperforms others at similar loads, with minimal error rates under extreme concurrency.
### Developer-Friendly
- **Simple Configuration**: Get started quickly with intuitive TOML configuration
- **Extensible Design**: Easily customize behavior for specific use cases
- **Lightweight Footprint**: Zero dependencies and efficient resource usage

### 4. **Streaming Support**
Supports response streaming via chunked transfer encoding, useful for large files or long-lived connections.
### 5. **Library**
Hteapot can be used as create library , allowing to extend or adapt it to your custom use.
## 🚀 Getting Started

### Installation

# Use
```bash
# Install from crates.io
cargo install hteapot

# Or build from source
git clone https://github.com/yourusername/hteapot.git
cd hteapot
cargo build --release
```

### Standalone Server

## standalone http server
#### Using a configuration file:

You can configure the server using a TOML file. Here's an example configuration:
Create a `config.toml` file:

```toml
[HTEAPOT]
port = 8081 # The port on which the server will listen for incoming connections.
host = "localhost" # The host address to bind the server to.
root = "public" # The root directory from which to serve files.
port = 8081 # The port to listen on
host = "localhost" # The host address to bind to
root = "public" # The root directory to serve files from
```

Then running with
Run the server:

```bash
$ hteapot ./config-file.toml
hteapot ./config.toml
```

or serving a file or folder directly
#### Quick serve a directory:

```bash
$ hteapot -s ./public/
hteapot -s ./public/
```

## Library
### As a Library

1. Add HTeaPot to your project:

For use hteapot as a library in rust
1. Install the library
```bash
$ cargo add hteapot
```
```bash
cargo add hteapot
```

2. Implement in your code:

2. Then you can use it in your project
```rust
use hteapot::{HttpStatus, HttpResponse, Hteapot, HttpRequest};

fn main() {
// Create a new server instance
let server = Hteapot::new("localhost", 8081);

// Define your request handler
server.listen(move |req: HttpRequest| {
HttpResponse::new(HttpStatus::IAmATeapot, "Hello, I am HTeaPot", None)
});
}
```

# Build
## Performance

1. Clone the repository:
```bash
git clone <repository_url>
```
HTeaPot has been benchmarked against other popular HTTP servers, consistently demonstrating excellent metrics:

2. Build the project:
```bash
cargo build --release
```
Run the server with a configuration file:
```bash
Copy code
./target/release/hteapot <config_file_path>
```
| Metric | HTeaPot | Industry Average |
|--------|---------|-----------------|
| Requests/sec | 70,000+ | 30,000-50,000 |
| Error rate | <0.1% | 0.5-2% |
| Latency (p99) | 5ms | 15-30ms |
| Memory usage | Low | Moderate |

## Roadmap

# Roadmap
- ✅ HTTP/1.1 support (keep-alive, chunked encoding)
- ✅ Library API
- ✅ Streaming responses
- ✅ Multipart form handling
- ✅ Basic routing system
- 🔜 HTTPS support
- 🔜 Compression (gzip/deflate)
- 🔜 WebSocket support
- 🔜 Enhanced documentation and examples

- [x] HTTP/1.1 support (keep-alive, chunked encoding)
- [x] Multipart form handling
- [x] Basic routing
- [x] Library support (use as a crate)
- [x] Streaming responses
- [ ] HTTPS support
- [ ] Compression (gzip/deflate)
- [ ] WebSocket support
- [ ] More modular architecture and documentation
## Contributing

# Contributing
We welcome contributions from the community! See our [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to get involved.

Contributions are welcome! Feel free to open issues or submit pull requests.
## License

[Contributor Guidelines](docs/CONSTRIBUTING.md)
HTeaPot is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

# License
## Acknowledgments

This project is licensed under the MIT License - see the LICENSE file for details.
- The Rust community for their exceptional tools and libraries
- Our contributors who have helped shape this project
- Users who provide valuable feedback and bug reports