Skip to content

Commit 5ec3a9a

Browse files
authored
Merge pull request #85 from Tuntii/update-docs-and-learning-path-817240201725488324
Update Documentation and Learning Path
2 parents 012e0d1 + 99d79b5 commit 5ec3a9a

File tree

14 files changed

+196
-26
lines changed

14 files changed

+196
-26
lines changed

docs/FEATURES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ RustApi::new()
11571157

11581158
```toml
11591159
[dependencies]
1160-
rustapi-rs = { version = "0.1.4", features = ["full"] }
1160+
rustapi-rs = { version = "0.1.275", features = ["full"] }
11611161
```
11621162

11631163
| Feature | Description |
@@ -1285,7 +1285,7 @@ let events = store.query()
12851285
### 1. Use `simd-json` (when available)
12861286

12871287
```toml
1288-
rustapi-rs = { version = "0.1.4", features = ["simd-json"] }
1288+
rustapi-rs = { version = "0.1.275", features = ["simd-json"] }
12891289
```
12901290

12911291
2-4x faster JSON parsing.

docs/GETTING_STARTED.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ Add RustAPI to your `Cargo.toml`:
2222

2323
```toml
2424
[dependencies]
25-
rustapi-rs = "0.1.233"
25+
rustapi-rs = "0.1.275"
2626
```
2727

2828
Or with specific features:
2929

3030
```toml
3131
[dependencies]
32-
rustapi-rs = { version = "0.1.233", features = ["jwt", "cors", "toon", "ws", "view"] }
32+
rustapi-rs = { version = "0.1.275", features = ["jwt", "cors", "toon", "ws", "view"] }
3333
```
3434

3535
### Available Features
@@ -358,7 +358,7 @@ ApiError::internal("message") // 500
358358
### CORS
359359

360360
```toml
361-
rustapi-rs = { version = "0.1.233", features = ["cors"] }
361+
rustapi-rs = { version = "0.1.275", features = ["cors"] }
362362
```
363363

364364
```rust
@@ -379,7 +379,7 @@ RustApi::new()
379379
### JWT Authentication
380380

381381
```toml
382-
rustapi-rs = { version = "0.1.233", features = ["jwt"] }
382+
rustapi-rs = { version = "0.1.275", features = ["jwt"] }
383383
```
384384

385385
```rust
@@ -409,7 +409,7 @@ async fn protected(user: AuthUser<Claims>) -> Json<Response> {
409409
### Rate Limiting
410410

411411
```toml
412-
rustapi-rs = { version = "0.1.233", features = ["rate-limit"] }
412+
rustapi-rs = { version = "0.1.275", features = ["rate-limit"] }
413413
```
414414

415415
```rust
@@ -427,7 +427,7 @@ RustApi::new()
427427
## TOON Format (LLM Optimization)
428428

429429
```toml
430-
rustapi-rs = { version = "0.1.233", features = ["toon"] }
430+
rustapi-rs = { version = "0.1.275", features = ["toon"] }
431431
```
432432

433433
```rust
@@ -458,7 +458,7 @@ Response includes token counting headers:
458458
Real-time bidirectional communication:
459459

460460
```toml
461-
rustapi-rs = { version = "0.1.233", features = ["ws"] }
461+
rustapi-rs = { version = "0.1.275", features = ["ws"] }
462462
```
463463

464464
```rust
@@ -495,7 +495,7 @@ websocat ws://localhost:8080/ws
495495
Server-side HTML rendering with Tera:
496496

497497
```toml
498-
rustapi-rs = { version = "0.1.233", features = ["view"] }
498+
rustapi-rs = { version = "0.1.275", features = ["view"] }
499499
```
500500

501501
Create a template file `templates/index.html`:
@@ -697,7 +697,7 @@ struct AnyBody { ... }
697697
Check that the `swagger-ui` feature is enabled (it's on by default):
698698

699699
```toml
700-
rustapi-rs = { version = "0.1.233", features = ["swagger-ui"] }
700+
rustapi-rs = { version = "0.1.275", features = ["swagger-ui"] }
701701
```
702702

703703
### CLI Commands Not Working

docs/PHILOSOPHY.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ We achieve this through:
7272
```toml
7373
# Your Cargo.toml - simple and stable
7474
[dependencies]
75-
rustapi-rs = "0.1"
75+
rustapi-rs = "0.1.275"
7676
```
7777

7878
You never write:
@@ -111,13 +111,13 @@ validator = "0.16"
111111

112112
```toml
113113
# Just the basics
114-
rustapi-rs = "0.1"
114+
rustapi-rs = "0.1.275"
115115

116116
# Kitchen sink
117-
rustapi-rs = { version = "0.1", features = ["full"] }
117+
rustapi-rs = { version = "0.1.275", features = ["full"] }
118118

119119
# Pick what you need
120-
rustapi-rs = { version = "0.1", features = ["jwt", "cors", "toon"] }
120+
rustapi-rs = { version = "0.1.275", features = ["jwt", "cors", "toon"] }
121121
```
122122

123123
| Feature | What You Get |

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RustAPI provides a stable, ergonomic public API. Internal dependencies (`hyper`,
3232

3333
```toml
3434
[dependencies]
35-
rustapi-rs = "0.1.4"
35+
rustapi-rs = "0.1.275"
3636
```
3737

3838
```rust

docs/cookbook/src/crates/rustapi_extras.md

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ The `insight` feature provides powerful real-time traffic analysis and debugging
8989

9090
```toml
9191
[dependencies]
92-
rustapi-extras = { version = "0.1", features = ["insight"] }
92+
rustapi-extras = { version = "0.1.275", features = ["insight"] }
9393
```
9494

9595
### Setup
@@ -118,3 +118,116 @@ async fn get_insights(State(store): State<Arc<InMemoryInsightStore>>) -> Json<In
118118
```
119119

120120
The `InsightStore` trait allows you to implement custom backends (e.g., ClickHouse or Elasticsearch) if you need long-term retention.
121+
122+
## Observability
123+
124+
The `otel` and `structured-logging` features bring enterprise-grade observability.
125+
126+
### OpenTelemetry
127+
128+
```rust
129+
use rustapi_extras::otel::{OtelLayer, OtelConfig};
130+
131+
let config = OtelConfig::default().service_name("my-service");
132+
let app = RustApi::new()
133+
.layer(OtelLayer::new(config));
134+
```
135+
136+
### Structured Logging
137+
138+
Emit logs as JSON for aggregators like Datadog or Splunk.
139+
140+
```rust
141+
use rustapi_extras::structured_logging::{StructuredLoggingLayer, JsonFormatter};
142+
143+
let app = RustApi::new()
144+
.layer(StructuredLoggingLayer::new(JsonFormatter::default()));
145+
```
146+
147+
## Advanced Security
148+
149+
### OAuth2 Client
150+
151+
The `oauth2-client` feature provides a complete client implementation.
152+
153+
```rust
154+
use rustapi_extras::oauth2::{OAuth2Client, OAuth2Config, Provider};
155+
156+
let config = OAuth2Config::new(
157+
Provider::Google,
158+
"client_id",
159+
"client_secret",
160+
"http://localhost:8080/callback"
161+
);
162+
let client = OAuth2Client::new(config);
163+
```
164+
165+
### Security Headers
166+
167+
Add standard security headers (HSTS, X-Frame-Options, etc.).
168+
169+
```rust
170+
use rustapi_extras::security_headers::SecurityHeadersLayer;
171+
172+
let app = RustApi::new()
173+
.layer(SecurityHeadersLayer::default());
174+
```
175+
176+
### API Keys
177+
178+
Simple API Key authentication strategy.
179+
180+
```rust
181+
use rustapi_extras::api_key::ApiKeyLayer;
182+
183+
let app = RustApi::new()
184+
.layer(ApiKeyLayer::new("my-secret-key"));
185+
```
186+
187+
## Resilience
188+
189+
### Circuit Breaker
190+
191+
Prevent cascading failures by stopping requests to failing upstreams.
192+
193+
```rust
194+
use rustapi_extras::circuit_breaker::CircuitBreakerLayer;
195+
196+
let app = RustApi::new()
197+
.layer(CircuitBreakerLayer::new());
198+
```
199+
200+
### Retry
201+
202+
Automatically retry failed requests with backoff.
203+
204+
```rust
205+
use rustapi_extras::retry::RetryLayer;
206+
207+
let app = RustApi::new()
208+
.layer(RetryLayer::default());
209+
```
210+
211+
## Optimization
212+
213+
### Caching
214+
215+
Cache responses based on headers or path.
216+
217+
```rust
218+
use rustapi_extras::cache::CacheLayer;
219+
220+
let app = RustApi::new()
221+
.layer(CacheLayer::new());
222+
```
223+
224+
### Request Deduplication
225+
226+
Prevent duplicate requests (e.g., from double clicks) from processing twice.
227+
228+
```rust
229+
use rustapi_extras::dedup::DedupLayer;
230+
231+
let app = RustApi::new()
232+
.layer(DedupLayer::new());
233+
```

docs/cookbook/src/crates/rustapi_jobs.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,44 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
8282
- **Redis**: High throughput persistence. Recommended for production.
8383
- **Postgres**: Transactional reliability (ACID). Best if you cannot lose jobs.
8484

85+
### Redis Backend
86+
87+
Enable the `redis` feature in `Cargo.toml`:
88+
89+
```toml
90+
[dependencies]
91+
rustapi-jobs = { version = "0.1.275", features = ["redis"] }
92+
```
93+
94+
```rust
95+
use rustapi_jobs::backend::redis::RedisBackend;
96+
97+
let backend = RedisBackend::new("redis://127.0.0.1:6379").await?;
98+
let queue = JobQueue::new(backend);
99+
```
100+
101+
### Postgres Backend
102+
103+
Enable the `postgres` feature in `Cargo.toml`. This uses `sqlx`.
104+
105+
```toml
106+
[dependencies]
107+
rustapi-jobs = { version = "0.1.275", features = ["postgres"] }
108+
```
109+
110+
```rust
111+
use rustapi_jobs::backend::postgres::PostgresBackend;
112+
use sqlx::postgres::PgPoolOptions;
113+
114+
let pool = PgPoolOptions::new().connect("postgres://user:pass@localhost/db").await?;
115+
let backend = PostgresBackend::new(pool);
116+
117+
// Ensure the jobs table exists
118+
backend.migrate().await?;
119+
120+
let queue = JobQueue::new(backend);
121+
```
122+
85123
## Reliability Features
86124

87125
The worker system includes built-in reliability features:

docs/cookbook/src/getting_started/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ cargo-rustapi --version
3030
If you prefer not to use the CLI, you can add RustAPI to your `Cargo.toml` manually:
3131

3232
```bash
33-
cargo add rustapi-rs@0.1.233
33+
cargo add rustapi-rs@0.1.275
3434
```
3535

3636
Or add this to your `Cargo.toml`:
3737

3838
```toml
3939
[dependencies]
40-
rustapi-rs = "0.1.233"
40+
rustapi-rs = "0.1.275"
4141
```
4242

4343
## Editor Setup

docs/cookbook/src/learning/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ Build AI-friendly APIs with TOON format and MCP support.
106106

107107
---
108108

109+
### 🏢 Path 5: Enterprise Platform
110+
111+
Build robust, observable, and secure systems.
112+
113+
| Step | Feature | Description |
114+
|------|---------|-------------|
115+
| 1 | **Observability** | Set up [OpenTelemetry and Structured Logging](../crates/rustapi_extras.md#observability) |
116+
| 2 | **Resilience** | Implement [Circuit Breakers and Retries](../crates/rustapi_extras.md#resilience) |
117+
| 3 | **Advanced Security** | Add [OAuth2 and Security Headers](../crates/rustapi_extras.md#advanced-security) |
118+
| 4 | **Optimization** | Configure [Caching and Deduplication](../crates/rustapi_extras.md#optimization) |
119+
120+
**Related Cookbook Recipes:**
121+
- [rustapi-extras: The Toolbox](../crates/rustapi_extras.md)
122+
123+
---
124+
109125
## 📦 Examples by Category
110126

111127
### Getting Started
@@ -163,6 +179,9 @@ Find examples by the RustAPI features they demonstrate:
163179
| Rate Limiting | `rate-limit-demo`, `auth-api` |
164180
| WebSockets (`ws` feature) | `websocket`, `graphql-api` |
165181
| TOON (`toon` feature) | `toon-api`, `mcp-server` |
182+
| OAuth2 (`oauth2-client`) | `auth-api` (extended) |
183+
| Circuit Breaker | `microservices` |
184+
| OpenTelemetry (`otel`) | `microservices-advanced` |
166185
| OpenAPI/Swagger | All examples |
167186

168187
---

docs/cookbook/src/recipes/csrf_protection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RustAPI's CSRF protection works by:
1515

1616
```toml
1717
[dependencies]
18-
rustapi-rs = { version = "0.1", features = ["csrf"] }
18+
rustapi-rs = { version = "0.1.275", features = ["csrf"] }
1919
```
2020

2121
```rust

docs/cookbook/src/recipes/file_uploads.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Handling file uploads efficiently is crucial. RustAPI allows you to stream `Mult
66

77
```toml
88
[dependencies]
9-
rustapi = { version = "0.1", features = ["multipart"] }
9+
rustapi = { version = "0.1.275", features = ["multipart"] }
1010
tokio = { version = "1", features = ["fs", "io-util"] }
1111
uuid = { version = "1", features = ["v4"] }
1212
```

0 commit comments

Comments
 (0)