Skip to content

Commit b91b52f

Browse files
authored
Merge pull request #38 from BennyFranciscus/add-axum
Add Axum: ergonomic Rust web framework built on Tokio/Hyper (~20k⭐)
2 parents b787288 + 53bdb38 commit b91b52f

5 files changed

Lines changed: 530 additions & 0 deletions

File tree

frameworks/axum/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "httparena-axum"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
axum = { version = "0.8", features = ["macros"] }
8+
tokio = { version = "1", features = ["full"] }
9+
tower-http = { version = "0.6", features = ["compression-gzip"] }
10+
hyper = { version = "1" }
11+
hyper-util = { version = "0.1", features = ["tokio"] }
12+
axum-server = { version = "0.7", features = ["tls-rustls"] }
13+
rustls = { version = "0.23", default-features = false, features = ["ring", "logging", "std", "tls12"] }
14+
rustls-pemfile = "2"
15+
serde = { version = "1", features = ["derive"] }
16+
serde_json = "1"
17+
num_cpus = "1"
18+
rusqlite = { version = "0.31", features = ["bundled"] }
19+
bytes = "1"
20+
tokio-rustls = "0.26"
21+
22+
[profile.release]
23+
opt-level = 3
24+
codegen-units = 1
25+
lto = "thin"
26+
panic = "abort"

frameworks/axum/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM rust:1.88 AS build
2+
WORKDIR /app
3+
COPY Cargo.toml .
4+
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release && rm -rf src/ target/release/httparena-axum* target/release/deps/httparena_axum*
5+
COPY src ./src
6+
RUN RUSTFLAGS="-C target-cpu=native" cargo build --release
7+
8+
FROM debian:bookworm-slim
9+
COPY --from=build /app/target/release/httparena-axum /server
10+
EXPOSE 8080
11+
CMD ["/server"]

frameworks/axum/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Axum
2+
3+
[Axum](https://github.com/tokio-rs/axum) is a web application framework built by the [Tokio](https://tokio.rs/) team. It leverages Tokio, Tower, and Hyper to provide an ergonomic and modular framework for building async Rust web services.
4+
5+
## Key Features
6+
7+
- Built on top of `hyper` and `tokio` — the Rust async ecosystem standards
8+
- Tower middleware compatibility — reuse the entire Tower ecosystem
9+
- Extractor-based request handling — type-safe, composable
10+
- Macro-free routing (though macros are available)
11+
- First-class WebSocket, SSE, and multipart support
12+
13+
## Implementation Notes
14+
15+
- Uses Axum 0.8 with Tokio multi-threaded runtime
16+
- Rustls for TLS/HTTP2 support via `axum-server`
17+
- `tower-http` compression layer for gzip
18+
- Pre-opened SQLite connection pool (one per CPU core) with mmap enabled
19+
- Static files and dataset loaded into memory at startup
20+
- Compiled with `-O3`, thin LTO, single codegen unit

frameworks/axum/meta.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"display_name": "axum",
3+
"language": "Rust",
4+
"type": "framework",
5+
"engine": "axum",
6+
"description": "Axum 0.8 on Tokio with Rustls for HTTP/2, compiled with -O3 and thin LTO.",
7+
"repo": "https://github.com/tokio-rs/axum",
8+
"enabled": true,
9+
"tests": [
10+
"baseline",
11+
"noisy",
12+
"pipelined",
13+
"limited-conn",
14+
"json",
15+
"upload",
16+
"compression",
17+
"mixed",
18+
"baseline-h2",
19+
"static-h2"
20+
]
21+
}

0 commit comments

Comments
 (0)