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
4 changes: 2 additions & 2 deletions docs/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ RustApi::new()

```toml
[dependencies]
rustapi-rs = { version = "0.1.4", features = ["full"] }
rustapi-rs = { version = "0.1.275", features = ["full"] }
```

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

```toml
rustapi-rs = { version = "0.1.4", features = ["simd-json"] }
rustapi-rs = { version = "0.1.275", features = ["simd-json"] }
```

2-4x faster JSON parsing.
Expand Down
18 changes: 9 additions & 9 deletions docs/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ Add RustAPI to your `Cargo.toml`:

```toml
[dependencies]
rustapi-rs = "0.1.233"
rustapi-rs = "0.1.275"
```

Or with specific features:

```toml
[dependencies]
rustapi-rs = { version = "0.1.233", features = ["jwt", "cors", "toon", "ws", "view"] }
rustapi-rs = { version = "0.1.275", features = ["jwt", "cors", "toon", "ws", "view"] }
```

### Available Features
Expand Down Expand Up @@ -358,7 +358,7 @@ ApiError::internal("message") // 500
### CORS

```toml
rustapi-rs = { version = "0.1.233", features = ["cors"] }
rustapi-rs = { version = "0.1.275", features = ["cors"] }
```

```rust
Expand All @@ -379,7 +379,7 @@ RustApi::new()
### JWT Authentication

```toml
rustapi-rs = { version = "0.1.233", features = ["jwt"] }
rustapi-rs = { version = "0.1.275", features = ["jwt"] }
```

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

```toml
rustapi-rs = { version = "0.1.233", features = ["rate-limit"] }
rustapi-rs = { version = "0.1.275", features = ["rate-limit"] }
```

```rust
Expand All @@ -427,7 +427,7 @@ RustApi::new()
## TOON Format (LLM Optimization)

```toml
rustapi-rs = { version = "0.1.233", features = ["toon"] }
rustapi-rs = { version = "0.1.275", features = ["toon"] }
```

```rust
Expand Down Expand Up @@ -458,7 +458,7 @@ Response includes token counting headers:
Real-time bidirectional communication:

```toml
rustapi-rs = { version = "0.1.233", features = ["ws"] }
rustapi-rs = { version = "0.1.275", features = ["ws"] }
```

```rust
Expand Down Expand Up @@ -495,7 +495,7 @@ websocat ws://localhost:8080/ws
Server-side HTML rendering with Tera:

```toml
rustapi-rs = { version = "0.1.233", features = ["view"] }
rustapi-rs = { version = "0.1.275", features = ["view"] }
```

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

```toml
rustapi-rs = { version = "0.1.233", features = ["swagger-ui"] }
rustapi-rs = { version = "0.1.275", features = ["swagger-ui"] }
```

### CLI Commands Not Working
Expand Down
8 changes: 4 additions & 4 deletions docs/PHILOSOPHY.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ We achieve this through:
```toml
# Your Cargo.toml - simple and stable
[dependencies]
rustapi-rs = "0.1"
rustapi-rs = "0.1.275"
```

You never write:
Expand Down Expand Up @@ -111,13 +111,13 @@ validator = "0.16"

```toml
# Just the basics
rustapi-rs = "0.1"
rustapi-rs = "0.1.275"

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

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

| Feature | What You Get |
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RustAPI provides a stable, ergonomic public API. Internal dependencies (`hyper`,

```toml
[dependencies]
rustapi-rs = "0.1.4"
rustapi-rs = "0.1.275"
```

```rust
Expand Down
115 changes: 114 additions & 1 deletion docs/cookbook/src/crates/rustapi_extras.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ The `insight` feature provides powerful real-time traffic analysis and debugging

```toml
[dependencies]
rustapi-extras = { version = "0.1", features = ["insight"] }
rustapi-extras = { version = "0.1.275", features = ["insight"] }
```

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

The `InsightStore` trait allows you to implement custom backends (e.g., ClickHouse or Elasticsearch) if you need long-term retention.

## Observability

The `otel` and `structured-logging` features bring enterprise-grade observability.

### OpenTelemetry

```rust
use rustapi_extras::otel::{OtelLayer, OtelConfig};

let config = OtelConfig::default().service_name("my-service");
let app = RustApi::new()
.layer(OtelLayer::new(config));
```

### Structured Logging

Emit logs as JSON for aggregators like Datadog or Splunk.

```rust
use rustapi_extras::structured_logging::{StructuredLoggingLayer, JsonFormatter};

let app = RustApi::new()
.layer(StructuredLoggingLayer::new(JsonFormatter::default()));
```

## Advanced Security

### OAuth2 Client

The `oauth2-client` feature provides a complete client implementation.

```rust
use rustapi_extras::oauth2::{OAuth2Client, OAuth2Config, Provider};

let config = OAuth2Config::new(
Provider::Google,
"client_id",
"client_secret",
"http://localhost:8080/callback"
);
let client = OAuth2Client::new(config);
```

### Security Headers

Add standard security headers (HSTS, X-Frame-Options, etc.).

```rust
use rustapi_extras::security_headers::SecurityHeadersLayer;

let app = RustApi::new()
.layer(SecurityHeadersLayer::default());
```

### API Keys

Simple API Key authentication strategy.

```rust
use rustapi_extras::api_key::ApiKeyLayer;

let app = RustApi::new()
.layer(ApiKeyLayer::new("my-secret-key"));
```

## Resilience

### Circuit Breaker

Prevent cascading failures by stopping requests to failing upstreams.

```rust
use rustapi_extras::circuit_breaker::CircuitBreakerLayer;

let app = RustApi::new()
.layer(CircuitBreakerLayer::new());
```

### Retry

Automatically retry failed requests with backoff.

```rust
use rustapi_extras::retry::RetryLayer;

let app = RustApi::new()
.layer(RetryLayer::default());
```

## Optimization

### Caching

Cache responses based on headers or path.

```rust
use rustapi_extras::cache::CacheLayer;

let app = RustApi::new()
.layer(CacheLayer::new());
```

### Request Deduplication

Prevent duplicate requests (e.g., from double clicks) from processing twice.

```rust
use rustapi_extras::dedup::DedupLayer;

let app = RustApi::new()
.layer(DedupLayer::new());
```
38 changes: 38 additions & 0 deletions docs/cookbook/src/crates/rustapi_jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,44 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
- **Redis**: High throughput persistence. Recommended for production.
- **Postgres**: Transactional reliability (ACID). Best if you cannot lose jobs.

### Redis Backend

Enable the `redis` feature in `Cargo.toml`:

```toml
[dependencies]
rustapi-jobs = { version = "0.1.275", features = ["redis"] }
```

```rust
use rustapi_jobs::backend::redis::RedisBackend;

let backend = RedisBackend::new("redis://127.0.0.1:6379").await?;
let queue = JobQueue::new(backend);
```

### Postgres Backend

Enable the `postgres` feature in `Cargo.toml`. This uses `sqlx`.

```toml
[dependencies]
rustapi-jobs = { version = "0.1.275", features = ["postgres"] }
```

```rust
use rustapi_jobs::backend::postgres::PostgresBackend;
use sqlx::postgres::PgPoolOptions;

let pool = PgPoolOptions::new().connect("postgres://user:pass@localhost/db").await?;
let backend = PostgresBackend::new(pool);

// Ensure the jobs table exists
backend.migrate().await?;

let queue = JobQueue::new(backend);
```

## Reliability Features

The worker system includes built-in reliability features:
Expand Down
4 changes: 2 additions & 2 deletions docs/cookbook/src/getting_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ cargo-rustapi --version
If you prefer not to use the CLI, you can add RustAPI to your `Cargo.toml` manually:

```bash
cargo add rustapi-rs@0.1.233
cargo add rustapi-rs@0.1.275
```

Or add this to your `Cargo.toml`:

```toml
[dependencies]
rustapi-rs = "0.1.233"
rustapi-rs = "0.1.275"
```

## Editor Setup
Expand Down
19 changes: 19 additions & 0 deletions docs/cookbook/src/learning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ Build AI-friendly APIs with TOON format and MCP support.

---

### 🏢 Path 5: Enterprise Platform

Build robust, observable, and secure systems.

| Step | Feature | Description |
|------|---------|-------------|
| 1 | **Observability** | Set up [OpenTelemetry and Structured Logging](../crates/rustapi_extras.md#observability) |
| 2 | **Resilience** | Implement [Circuit Breakers and Retries](../crates/rustapi_extras.md#resilience) |
| 3 | **Advanced Security** | Add [OAuth2 and Security Headers](../crates/rustapi_extras.md#advanced-security) |
| 4 | **Optimization** | Configure [Caching and Deduplication](../crates/rustapi_extras.md#optimization) |

**Related Cookbook Recipes:**
- [rustapi-extras: The Toolbox](../crates/rustapi_extras.md)

---

## 📦 Examples by Category

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

---
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbook/src/recipes/csrf_protection.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RustAPI's CSRF protection works by:

```toml
[dependencies]
rustapi-rs = { version = "0.1", features = ["csrf"] }
rustapi-rs = { version = "0.1.275", features = ["csrf"] }
```

```rust
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbook/src/recipes/file_uploads.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Handling file uploads efficiently is crucial. RustAPI allows you to stream `Mult

```toml
[dependencies]
rustapi = { version = "0.1", features = ["multipart"] }
rustapi = { version = "0.1.275", features = ["multipart"] }
tokio = { version = "1", features = ["fs", "io-util"] }
uuid = { version = "1", features = ["v4"] }
```
Expand Down
4 changes: 2 additions & 2 deletions docs/cookbook/src/recipes/http3_quic.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ HTTP/3 support is optional and can be enabled via feature flags in `Cargo.toml`.

```toml
[dependencies]
rustapi-rs = { version = "0.1.9", features = ["http3"] }
rustapi-rs = { version = "0.1.275", features = ["http3"] }
# For development with self-signed certificates
rustapi-rs = { version = "0.1.9", features = ["http3", "http3-dev"] }
rustapi-rs = { version = "0.1.275", features = ["http3", "http3-dev"] }
```

## Running an HTTP/3 Server
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbook/src/recipes/jwt_auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Enable the `jwt` feature in your `Cargo.toml`:

```toml
[dependencies]
rustapi-rs = { version = "0.1", features = ["jwt"] }
rustapi-rs = { version = "0.1.275", features = ["jwt"] }
serde = { version = "1", features = ["derive"] }
```

Expand Down
Loading
Loading