#http-server #http #http-request #serve-static #extend #requests

bin+lib hteapot

HTeaPot is a lightweight HTTP server library designed to be easy to use and extend

7 releases

Uses old Rust 2015

0.3.1 Nov 7, 2024
0.3.0 Nov 6, 2024
0.2.6 Sep 30, 2024
0.2.5 Jul 6, 2024
0.1.0 Jun 6, 2024

#1401 in Web programming

Download history 24/week @ 2024-09-13 12/week @ 2024-09-20 162/week @ 2024-09-27 29/week @ 2024-10-04 8/week @ 2024-10-11 3/week @ 2024-10-18 184/week @ 2024-11-01 76/week @ 2024-11-08 7/week @ 2024-11-15 3/week @ 2024-11-22

270 downloads per month
Used in cafetera

MIT license

43KB
1K SLoC

🍵 HteaPot HTTP Server

Spanish | English

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.

Features

1. Threaded Architecture

  • Custom thread-based system, capable of handling around 70,000 requests per second.
  • Emphasizes resilience over peak speed, making it robust under heavy load.

2. Performance Under Load

  • Steady performance under high concurrency, managing up to 50,000 requests per second with increased connections.
  • Other's performance degrades significantly under high load, while Hteapot remains stable.

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.

Use

standalone http server

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

[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.

Then running with

$ hteapot ./config-file.toml

or serving a file or folder directly

$ hteapot -s ./public/

Library

For use hteapot as a library in rust

  1. Install the library
$ cargo add hteapot
  1. Then you can use it in your project
use hteapot::{HttpStatus, Hteapot, HttpRequest};

fn main() {
    let server = Hteapot::new("localhost", 8081);
     teapot.listen(move|req| {
       HttpResponse::new(HttpStatus::IAmATeapot, "Hello i am HTeaPot", None);

     }

}

Build

  1. Clone the repository:
git clone <repository_url>
  1. Build the project:
cargo build --release

Run the server with a configuration file:

Copy code
./target/release/hteapot <config_file_path>

Contributing

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

License

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

No runtime deps