1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! HTTP Response Compression Middleware for Armature
//!
//! This crate provides middleware for compressing HTTP responses using various
//! compression algorithms including gzip, brotli, and zstd.
//!
//! # Features
//!
//! - `gzip` - Enable gzip compression (enabled by default)
//! - `brotli` - Enable brotli compression (enabled by default)
//! - `zstd` - Enable zstd compression
//! - `full` - Enable all compression algorithms
//!
//! # Example
//!
//! ```rust,no_run
//! use armature_compression::{CompressionMiddleware, CompressionConfig, CompressionAlgorithm};
//!
//! // Create middleware with default settings (auto-select best algorithm)
//! let middleware = CompressionMiddleware::new();
//!
//! // Or with specific configuration
//! let config = CompressionConfig::builder()
//! .algorithm(CompressionAlgorithm::Brotli)
//! .min_size(1024) // Only compress responses > 1KB
//! .level(6) // Compression level (1-9 for most algorithms)
//! .build();
//! let middleware = CompressionMiddleware::with_config(config);
//! ```
//!
//! # Compression Algorithm Selection
//!
//! When using `CompressionAlgorithm::Auto`, the middleware will select the best
//! compression algorithm based on the client's `Accept-Encoding` header:
//!
//! 1. **Brotli** (`br`) - Best compression ratio, preferred for text content
//! 2. **Zstd** (`zstd`) - Fast compression with good ratios
//! 3. **Gzip** (`gzip`) - Most widely supported, good fallback
//!
//! # Content Types
//!
//! By default, the middleware compresses the following content types:
//!
//! - `text/*` (HTML, CSS, JavaScript, plain text, etc.)
//! - `application/json`
//! - `application/javascript`
//! - `application/xml`
//! - `image/svg+xml`
//!
//! Binary content types like images, videos, and already-compressed files
//! are not compressed by default.
pub use CompressionAlgorithm;
pub use ;
pub use CompressionError;
pub use CompressionMiddleware;
pub use ;
/// Result type for compression operations
pub type Result<T> = Result;