Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
edition = "2024"
name = "hteapot"
version = "0.5.0" # release candidate
exclude = ["hteapot.toml", "public/", "readme.md"]
version = "0.5.0"
exclude = ["config.toml", "demo/", "readme.md"]
license = "MIT"
keywords = ["HTTP", "HTTP-SERVER"]
description = "HTeaPot is a lightweight HTTP server library designed to be easy to use and extend."
Expand All @@ -15,6 +16,5 @@ authors = ["Alb Ruiz G. <me@albruiz.dev>"]
name = "hteapot"
path = "src/hteapot/mod.rs"


[[bin]]
name = "hteapot"
File renamed without changes.
Binary file added demo/public/favicon.ico
Binary file not shown.
File renamed without changes.
File renamed without changes.
11,352 changes: 11,352 additions & 0 deletions demo/public/large-file.json

Large diffs are not rendered by default.

File renamed without changes.
5 changes: 5 additions & 0 deletions demo/public/subfolder/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<bod>
<h1>Hello from the subfolder</h1>
</bod>
</html>
9 changes: 9 additions & 0 deletions examples/basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use hteapot::{Hteapot, HttpRequest, HttpResponse, HttpStatus};

fn main() {
let server = Hteapot::new("localhost", 8081);
server.listen(move |_req: HttpRequest| {
// This will be executed for each request
HttpResponse::new(HttpStatus::IAmATeapot, "Hello, I am HTeaPot", None)
});
}
17 changes: 17 additions & 0 deletions examples/stream.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::{thread, time::Duration};

use hteapot::{Hteapot, HttpRequest, StreamedResponse};

fn main() {
let server = Hteapot::new("localhost", 8081);
server.listen(move |_req: HttpRequest| {
let times = 5;
StreamedResponse::new(move |sender| {
for i in 0..times {
let data = format!("{i}-abcd\n").into_bytes();
let _ = sender.send(data);
thread::sleep(Duration::from_secs(1));
}
})
});
}
12 changes: 9 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🍵 HteaPot HTTP Server

[Spanish](docs/readme-es.md) | English
[Spanish](docs/i8n/readme-es.md) | 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.

Expand All @@ -11,14 +11,18 @@ Hteapot is a powerful, Rust-based HTTP server and library designed for high-perf


### 2. **Performance Under Load**
Steady performance under high concurrency, managing up to **50,000 requests per second** with increased connections.
Steady performance under high concurrency


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

### 4. **Streaming Support**
- Supports response streaming via chunked transfer encoding, useful for large files or long-lived connections.
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.


# Use

Expand Down Expand Up @@ -96,6 +100,8 @@ Copy code

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

[Contributor Guidelines](docs/CONSTRIBUTING.md)

# License

This project is licensed under the MIT License - see the LICENSE file for details.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn main() {
);
}
}

let mut full_path = format!("{}{}", config.root, req.path.clone());
if Path::new(full_path.as_str()).is_dir() {
let separator = if full_path.ends_with('/') { "" } else { "/" };
Expand Down