Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Az107/HTeaPot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🍵 HTeaPot

A blazing-fast, minimalist HTTP server library built with Rust

Crates.io Documentation License: MIT GitHub Repo stars

English | Español

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

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

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

Getting Started

Installation

# 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

Using a configuration file:

Create a config.toml file:

[HTEAPOT]
port = 8081        # The port to listen on
host = "localhost" # The host address to bind to
root = "public"    # The root directory to serve files from

Run the server:

hteapot ./config.toml

Quick serve a directory:

hteapot -s ./public/

As a Library

  1. Add HTeaPot to your project:
cargo add hteapot
  1. Implement in your code:
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)
    });
}

Performance

HTeaPot has been benchmarked against other popular HTTP servers, consistently demonstrating excellent metrics:

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

  • 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

Contributing

We welcome contributions from the community! See our CONTRIBUTING.md for guidelines on how to get involved.

License

HTeaPot is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • 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