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
- Updated **Module 6: OpenAPI & HATEOAS** to include OpenAPI References.
17
+
- Updated **Module 14: High Performance** to include Response Compression.
18
+
19
+
### Cookbook Recipes
20
+
-**Created `recipes/compression.md`:** Detailed guide on using `CompressionLayer` with Gzip/Brotli/Deflate.
21
+
-**Created `recipes/openapi_refs.md`:** Explanation of automatic `$ref` generation with `#[derive(Schema)]` and handling recursive types.
22
+
-**Updated `recipes/file_uploads.md`:** Fixed body limit configuration (using `RustApi::new().body_limit(...)`), improved security notes, and added a complete example.
23
+
-**Updated `recipes/db_integration.md`:** Expanded with production connection pool settings, transactions, and integration testing with `testcontainers`.
24
+
25
+
### Documentation Management
26
+
-**Created `docs/.agent/docs_inventory.md`:** Full inventory of documentation files and their status.
27
+
-**Created `docs/.agent/docs_coverage.md`:** Mapping of features to documentation pages.
28
+
29
+
## Improvements
30
+
- Addressed user feedback regarding missing recipes for DB integration patterns, file uploads, error types, OpenAPI refs, and compression.
31
+
- Standardized the Learning Path structure.
32
+
33
+
## TODOs
34
+
- Verify `rustapi-grpc` examples with the latest `tonic` version.
35
+
- Add a specific recipe for `rustapi-view` with HTMX.
RustAPI supports automatic response compression (Gzip, Deflate, Brotli) via the `CompressionLayer`. This middleware negotiates the best compression algorithm based on the client's `Accept-Encoding` header.
4
+
5
+
## Dependencies
6
+
7
+
To use compression, you must enable the `compression` feature in `rustapi-core` (or `rustapi-rs`). For Brotli support, enable `compression-brotli`.
8
+
9
+
```toml
10
+
[dependencies]
11
+
rustapi-rs = { version = "0.1.335", features = ["compression", "compression-brotli"] }
12
+
```
13
+
14
+
## Basic Usage
15
+
16
+
The simplest way to enable compression is to add the layer to your application:
Images (JPEG, PNG), Videos, and Archives (ZIP) are already compressed. Compressing them again wastes CPU cycles and might even increase the file size. The default configuration excludes most binary formats, but be careful with custom types.
76
+
77
+
### 2. Set Minimum Size
78
+
Compressing very small responses (e.g., "OK") can actually make them larger due to framing overhead. The default 1KB threshold is a good starting point.
79
+
80
+
### 3. Order of Middleware
81
+
Compression should usually be one of the *last* layers added (outermost), so it compresses the final response after other middleware (like logging or headers) have run.
82
+
83
+
```rust
84
+
RustApi::new()
85
+
.layer(CompressionLayer::new()) // Runs last on response (first on request)
86
+
.layer(LoggingLayer::new()) // Runs before compression on response
0 commit comments