Skip to content

Commit 2c32c7f

Browse files
committed
feat: Update changelog for version 0.3.3, add custom headers support, and fix client request headers bug
1 parent f7c311d commit 2c32c7f

File tree

6 files changed

+92
-445
lines changed

6 files changed

+92
-445
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
9+
## [0.3.3] - 2025-10-02
10+
11+
### Added
12+
- **Custom Headers Support in HTTP Client**
13+
- Added `.header()` method to `RequestBuilder` for setting custom HTTP headers.
14+
- HTTP client requests now properly transmit custom headers to the server.
15+
16+
### Fixed
17+
- **Client Request Headers Bug**
18+
- Fixed issue where custom headers added via `.header()` were stored but not sent with requests.
19+
- Updated `send_request_with_optimization` to accept and forward headers parameter.
20+
- Enhanced `RequestBuilder` in `http_client` module to support custom header insertion.
21+
22+
### Changed
23+
- **Clippy Configuration**
24+
- Updated `too-many-arguments-threshold` from 7 to 10 to accommodate enhanced method signatures.
25+
26+
### Internal
27+
- **Code Quality**
28+
- Improved method signatures for better header propagation throughout the request pipeline.
29+
- Added comprehensive header support documentation in code comments.
30+
831
## [0.3.2] - 2025-09-30
932

1033
### Added

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "kode-bridge"
33
authors = ["Tunglies"]
4-
version = "0.3.2"
4+
version = "0.3.3"
55
edition = "2021"
66
description = "Modern HTTP Over IPC library for Rust with both client and server support (Unix sockets, Windows named pipes)."
77
license = "Apache-2.0"
@@ -58,6 +58,11 @@ path = "examples/request.rs"
5858
name = "request_large"
5959
path = "examples/request_large.rs"
6060

61+
[[example]]
62+
name = "server"
63+
path = "examples/server.rs"
64+
required-features = ["server"]
65+
6166
[[example]]
6267
name = "http_server"
6368
path = "examples/http_server.rs"

README.md

Lines changed: 41 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
55
[![Crates.io](https://img.shields.io/crates/v/kode-bridge.svg)](https://crates.io/crates/kode-bridge)
66

7-
**[中文](./README_CN.md) | English**
7+
<!-- **[中文](./README_CN.md) | English** -->
88

99
**kode-bridge** is a modern Rust library that implements **HTTP Over IPC** for cross-platform (macOS, Linux, Windows) communication. It provides both **client and server** capabilities with elegant HTTP-style request/response and real-time streaming through Unix Domain Sockets or Windows Named Pipes, featuring a fluent API similar to reqwest with comprehensive connection pooling, advanced error handling, and high-performance streaming.
1010

@@ -53,88 +53,70 @@ serde_json = "1.0"
5353
### Basic Usage
5454

5555
```rust
56-
use kode_bridge::{IpcHttpClient, IpcStreamClient};
57-
use serde_json::json;
56+
use dotenvy::dotenv;
57+
use kode_bridge::{IpcHttpClient, Result};
58+
use std::env;
5859
use std::time::Duration;
5960

6061
#[tokio::main]
61-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
62-
// Automatically detect platform and use appropriate IPC path
62+
async fn main() -> Result<()> {
63+
dotenv().ok();
64+
65+
// Use platform-appropriate environment variable with fallback
6366
#[cfg(unix)]
64-
let ipc_path = "/tmp/my_service.sock";
67+
let ipc_path = env::var("CUSTOM_SOCK").unwrap_or_else(|_| "/tmp/example.sock".to_string());
6568
#[cfg(windows)]
66-
let ipc_path = r"\\.\pipe\my_service";
67-
68-
// HTTP-style client for request/response
69-
let client = IpcHttpClient::new(ipc_path)?;
70-
71-
// 🔥 New fluent API - like reqwest!
72-
let response = client
73-
.get("/api/version")
74-
.timeout(Duration::from_secs(5))
75-
.send()
76-
.await?;
77-
78-
println!("Status: {}", response.status());
79-
println!("Success: {}", response.is_success());
80-
81-
// Type-safe JSON parsing
82-
#[derive(serde::Deserialize)]
83-
struct ApiResponse {
84-
version: String,
85-
meta: bool,
86-
}
87-
88-
let data: ApiResponse = response.json()?;
89-
println!("Version: {}", data.version);
90-
91-
// POST with JSON body
92-
let update_data = json!({"user": "alice", "action": "login"});
69+
let ipc_path = env::var("CUSTOM_PIPE").unwrap_or_else(|_| r"\\.\pipe\example".to_string());
70+
71+
println!("📡 Connecting to: {}", ipc_path);
72+
73+
// Create client with modern API
74+
let client = IpcHttpClient::new(&ipc_path)?;
75+
76+
// Use the new fluent API with custom headers and timeout
9377
let response = client
94-
.post("/api/auth")
95-
.json_body(&update_data)
78+
.get("/version")
79+
.header("Authorization", "Bearer token123")
80+
.header("X-Custom-Header", "custom-value")
9681
.timeout(Duration::from_secs(10))
9782
.send()
9883
.await?;
99-
100-
if response.is_success() {
101-
println!("Auth successful!");
84+
85+
println!("🔍 Response Details:");
86+
println!(" Status: {}", response.status());
87+
println!(" Success: {}", response.is_success());
88+
println!(" Content Length: {}", response.content_length());
89+
90+
// Parse and display JSON response
91+
match response.json_value() {
92+
Ok(json) => println!("📄 JSON Response: {:#}", json),
93+
Err(e) => {
94+
println!("📄 Raw Response: {:?}", response.body()?);
95+
println!("⚠️ JSON parse error: {}", e);
96+
}
10297
}
103-
104-
// Real-time streaming client
105-
let stream_client = IpcStreamClient::new(ipc_path)?;
106-
107-
// Monitor traffic data in real-time
108-
#[derive(serde::Deserialize, Debug)]
109-
struct TrafficData {
110-
up: u64,
111-
down: u64,
98+
99+
// Show pool stats if available
100+
if let Some(stats) = client.pool_stats() {
101+
println!("📊 Pool Stats: {}", stats);
112102
}
113-
114-
let traffic_data: Vec<TrafficData> = stream_client
115-
.get("/traffic")
116-
.timeout(Duration::from_secs(5))
117-
.json_results()
118-
.await?;
119-
120-
println!("Collected {} traffic samples", traffic_data.len());
121-
103+
122104
Ok(())
123105
}
124106
```
125107

126108
### Server Usage
127109

128110
```rust
129-
use kode_bridge::{IpcHttpServer, Router, HttpResponse, Result};
111+
use kode_bridge::{ipc_http_server::{HttpResponse, IpcHttpServer, Router}, Result};
130112
use serde_json::json;
131113

132114
#[tokio::main]
133115
async fn main() -> Result<()> {
134116
// Create HTTP server with routing
135117
let router = Router::new()
136-
.get("/health", |_| async move {
137-
HttpResponse::json(&json!({"status": "healthy"}))
118+
.get("/version", |_| async move {
119+
HttpResponse::json(&json!({"version": "1.0.0"}))
138120
})
139121
.post("/api/data", |ctx| async move {
140122
let data: serde_json::Value = ctx.json()?;

0 commit comments

Comments
 (0)