Skip to content

Commit a034ac7

Browse files
authored
Merge pull request #4 from denislituev/rework_features
Rework features
2 parents eb7a960 + 49a87ec commit a034ac7

File tree

3 files changed

+31
-39
lines changed

3 files changed

+31
-39
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ name = "proxy_bench"
8484
harness = false
8585

8686
[features]
87-
default = ["cli", "tls"]
87+
default = ["cli", "tls", "api"]
8888
cli = ["dep:clap", "dep:tracing-subscriber"]
8989
tls = ["dep:hyper-tls"]
9090
api = ["dep:serde", "dep:serde_json"]
91-
full = ["cli", "tls", "api"]

README.md

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Add or modify request headers.
184184

185185
```caddy
186186
localhost:8080 {
187-
header X-Forwarded-For {remote_host}
187+
header X-Request-ID {uuid}
188188
header X-Custom-Header custom-value
189189
reverse_proxy backend:3000
190190
}
@@ -253,7 +253,7 @@ localhost:8080 {
253253

254254
```caddy
255255
localhost:8080 {
256-
header X-Forwarded-For {remote_host}
256+
header X-Forwarded-For {header.X-Forwarded-For}
257257
header X-Request-ID {uuid}
258258
uri_replace /api /backend
259259
reverse_proxy http://backend:3000
@@ -278,63 +278,56 @@ Use placeholders in header values:
278278
- `{header.Name}` - Value of request header with that name
279279
- `{env.VAR}` - Value of environment variable
280280
- `{uuid}` - Random UUID
281-
- `{remote_host}` - Remote host (requires `auth` feature)
282281

283282
## Features
284283

285284
### Default Features
286285

287-
- `cli` - Command-line interface support (enabled by default)
288-
- `tls` - HTTPS backend support (enabled by default)
286+
- `cli` - Command-line interface support
287+
- `tls` - HTTPS backend support
288+
- `api` - Management API for runtime configuration
289289

290290
### Optional Features
291291

292292
```toml
293+
# Minimal - core proxy only (for embedding in other applications)
294+
[dependencies]
295+
tiny-proxy = { version = "0.1", default-features = false }
296+
297+
# With HTTPS backend support
298+
[dependencies]
299+
tiny-proxy = { version = "0.1", default-features = false, features = ["tls"] }
300+
301+
# With management API
293302
[dependencies]
294-
tiny-proxy = { version = "0.1", features = ["full"] }
303+
tiny-proxy = { version = "0.1", default-features = false, features = ["tls", "api"] }
295304

296-
# Or select specific features
297-
tiny-proxy = { version = "0.1", features = ["cli", "tls", "api"] }
305+
# Full standalone (same as default)
306+
[dependencies]
307+
tiny-proxy = { version = "0.1" }
298308
```
299309

300310
#### `cli` (default)
301311

302312
Enable CLI dependencies and `tiny-proxy` binary.
303313

304-
#### `auth`
305-
306-
Authentication and authorization support:
307-
308-
```rust
309-
use tiny_proxy::auth;
310-
311-
// Validate token
312-
let is_valid = auth::validate_token(&req, "http://auth-service/validate").await?;
313-
314-
// Process header substitutions
315-
let value = auth::process_header_substitution("Bearer {header.Authorization}", &req)?;
316-
```
317-
318314
#### `tls` (default)
319315

320316
Enable HTTPS backend support using `hyper-tls`.
321317

322-
#### `api`
318+
#### `api` (default)
323319

324320
Management API for runtime configuration:
325321

326322
```rust
327323
use tiny_proxy::api;
324+
use std::sync::Arc;
328325
use tokio::sync::RwLock;
329326

330327
let config = Arc::new(RwLock::new(Config::from_file("config.caddy")?));
331328
api::start_api_server("127.0.0.1:8081", config).await?;
332329
```
333330

334-
#### `full`
335-
336-
Enable all features (`cli`, `auth`, `api`).
337-
338331
## API Documentation
339332

340333
See the [module documentation](https://docs.rs/tiny-proxy) for detailed API reference.
@@ -418,17 +411,20 @@ tiny-proxy/
418411
### Build with Features
419412

420413
```bash
421-
# CLI only (default)
414+
# Default (CLI + TLS + API)
422415
cargo build
423416

424417
# Library only (no CLI dependencies)
425418
cargo build --no-default-features
426419

427-
# Full features
428-
cargo build --features full
420+
# Library with HTTPS support
421+
cargo build --no-default-features --features tls
429422

430-
# Specific features
431-
cargo build --features auth,api
423+
# Library with API for config management
424+
cargo build --no-default-features --features tls,api
425+
426+
# CLI without API
427+
cargo build --no-default-features --features cli,tls
432428
```
433429

434430
### Run Examples
@@ -439,9 +435,6 @@ cargo run --example basic
439435

440436
# Background execution
441437
cargo run --example background
442-
443-
# Hot-reload (with auth feature)
444-
cargo run --example hot_reload --features auth
445438
```
446439

447440
## Roadmap

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use tracing_subscriber::EnvFilter;
55
use tiny_proxy::cli::Cli;
66
use tiny_proxy::config::Config;
77

8-
#[cfg(feature = "cli")]
8+
#[cfg(feature = "api")]
99
use std::sync::Arc;
1010

11-
#[cfg(feature = "cli")]
11+
#[cfg(feature = "api")]
1212
use tokio::sync::{broadcast, RwLock};
1313

1414
#[cfg(feature = "api")]

0 commit comments

Comments
 (0)