You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Most Rust frameworks force you to choose: Speed (Actix) OR Ergonomics (Axum).**
19
-
RustAPI gives you **both**.
18
+
RustAPI is a Rust web framework built on **hyper 1.x** and **tokio**, designed for minimal boilerplate while retaining full control over performance. It uses a **facade architecture** (`rustapi-rs`) that shields user code from internal crate changes, keeping the public API stable as internals evolve.
20
19
21
-
We built the framework we wanted: **FastAPI's developer experience** backed by **Rust's raw performance**.
22
-
No boilerplate. No fighting the borrow checker for simple handlers. Just code that flies.
20
+
Key design goals:
21
+
-**Ergonomic handler signatures** inspired by FastAPI and Axum
22
+
-**Native TOON format** for token-efficient LLM responses
23
+
-**Auto-discovery** of routes via procedural macros and link-time registration
24
+
-**Three-tier request execution** (ultra fast / fast / full) to minimize overhead
23
25
24
-
## 🧠 The Killer Feature: AI-First Architecture
26
+
## What Sets RustAPI Apart
25
27
26
-
**Problem:** Standard JSON APIs are verbose and expensive for Large Language Models (LLMs).
> "RustAPI isn't just a web server; it's the native language of your AI agents."
38
+
This means a simple `GET /health` endpoint with no middleware runs at near-zero overhead, while other endpoints on the same server can use JWT, CORS, and rate limiting through the full path.
36
39
37
-
##🔄 Time-Travel Debugging (NEW in v0.1.300)
40
+
### Facade Architecture with Contract Enforcement
38
41
39
-
**Production debugging shouldn't be a nightmare.** RustAPI's Replay system records and replays HTTP requests with surgical precision.
42
+
User code imports only from `rustapi-rs`. Internal crates (`rustapi-core`, `rustapi-macros`, etc.) can be refactored freely without breaking user code. The public API surface is tracked via committed `cargo public-api` snapshots, and CI enforces labeling rules (`breaking` / `feature`) on any PR that changes them.
43
+
44
+
### Link-Time Auto-Discovery
45
+
46
+
Routes annotated with `#[rustapi_rs::get("/...")]` are registered to a `linkme` distributed slice at link time — no manual route registration or inventory macros needed. `RustApi::auto()` collects them and builds a `BTreeMap`-ordered radix tree router via `matchit`.
47
+
48
+
### TOON: Token-Oriented Object Notation
49
+
50
+
A compact serialization format that reduces token counts by **50-58%** compared to JSON. `Toon<T>` is a drop-in replacement for `Json<T>`. `LlmResponse<T>` performs automatic content negotiation based on `Accept` headers and adds headers like `X-Token-Count-JSON`, `X-Token-Count-TOON`, and `X-Token-Savings` for observability.
51
+
52
+
### Built-in Resilience Primitives
53
+
54
+
RustAPI ships circuit breaker and retry middleware as first-class features, not third-party crate bolt-ons:
55
+
56
+
-**Circuit Breaker** (`CircuitBreakerLayer`): Fault tolerance with open/half-open/closed states
57
+
-**Retry** with exponential backoff
58
+
-**Rate Limiting** (IP-based, per-route)
59
+
-**Body Limit** with configurable max size (default 1 MB)
60
+
61
+
### Environment-Aware Error Masking
62
+
63
+
All error responses include a unique `error_id` (`err_{uuid}`) for log correlation. In production (`RUSTAPI_ENV=production`), 5xx error details are automatically masked to `"An internal error occurred"` while validation errors (4xx) pass through intact.
64
+
65
+
### Request Replay & Time-Travel Debugging
66
+
67
+
Record and replay HTTP request/response pairs for production debugging:
|**DX (Simplicity)**| 🟢 **High**| 🔴 Low | 🟡 Medium | 🟢 High |
70
-
|**Boilerplate**|**Zero**| High | Medium | Zero |
71
-
|**AI/LLM Native**| ✅ **Yes**| ❌ No | ❌ No | ❌ No |
72
-
|**Time-Travel Debug**| ✅ **Built-in**| ❌ No | ❌ No | ⚠️ 3rd-party |
73
-
|**Stability Logic**| 🛡️ **Facade**| ⚠️ Direct | ⚠️ Direct | ✅ Stable |
92
+
`#[derive(Schema)]` generates OpenAPI schemas at compile time. `RustApi::auto()` assembles the full spec with reference integrity validation. Swagger UI is served at `/docs` by default. No external code generators or YAML files needed.
74
93
75
-
##🚀 30-Second Start
94
+
### Async Validation with Application State
76
95
77
-
Write your API in 5 lines. It's that simple.
96
+
`AsyncValidatedJson<T>` can access application state (e.g., database connections) during validation. The extractor clones `ValidationContext` from request state, enabling rules like "username must be unique" at the validation layer.
97
+
98
+
### Background Jobs
99
+
100
+
`rustapi-jobs` provides an async job queue with three backends (Memory, Redis, Postgres), retry with exponential backoff, dead letter queues, and scheduled execution.
101
+
102
+
### Side-by-Side gRPC + HTTP
103
+
104
+
`rustapi-grpc` enables running Tonic-based gRPC services alongside RustAPI HTTP handlers in the same process via `run_rustapi_and_grpc`.
105
+
106
+
### Additional Built-in Capabilities
107
+
108
+
| Capability | Notes |
109
+
|:-----------|:------|
110
+
| WebSocket with permessage-deflate | Full compression negotiation via `protocol-ws`|
// 1 line to rule them all: Auto-discovery, OpenAPI, Validation
93
150
RustApi::auto().run("127.0.0.1:8080").await
94
151
}
95
152
```
96
153
97
-
Prefer a shorter macro prefix? You can rename the crate in `Cargo.toml` and use the same macros:
154
+
`RustApi::auto()` collects all macro-annotated handlers, generates OpenAPI documentation (served at `/docs`), and starts a multi-threaded tokio runtime.
155
+
156
+
You can shorten the macro prefix by renaming the crate:
98
157
99
158
```toml
100
159
[dependencies]
@@ -108,57 +167,45 @@ use api::prelude::*;
108
167
asyncfnlist_users() ->&'staticstr { "ok" }
109
168
```
110
169
111
-
**That's it.** You get:
112
-
* ✅ **Swagger UI** at `/docs`
113
-
* ✅ **Input Validation**
114
-
* ✅ **Multi-threaded Runtime**
115
-
* ✅ **Zero Config**
116
-
117
-
## Feature Taxonomy (Stable)
170
+
## Feature Flags
118
171
119
-
RustAPI now groups features into three namespaces:
0 commit comments