Skip to content

Commit eee26db

Browse files
committed
Fix code formatting and add quick install guide
- Remove trailing whitespace - Format code according to rustfmt standards - Add quick install section in README with curl | bash method - Improve installation documentation structure
1 parent 4f1068d commit eee26db

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [1.0.1] - 2025-11-07
99

1010
### Added
11+
1112
- 🎯 **Target parameter shorthand support** - Now you can use simplified formats for local proxying:
1213
- Port only: `apxy -t 3000` instead of `apxy -t http://localhost:3000`
1314
- With colon: `apxy -t :3000`
1415
- Host:port: `apxy -t localhost:3000`
1516
- Full URLs still work: `apxy -t http://localhost:3000`
16-
1717
- 🔧 **Custom authentication parameter names** - Customize the URL parameter and header names for authentication:
1818
- `--auth-param` to set custom URL parameter name (default: `token`)
1919
- `--auth-header` to set custom header name (default: `X-Auth-Token`)
2020
- Example: `apxy -t 3000 -a secret --auth-param apikey --auth-header Authorization`
2121

2222
### Changed
23+
2324
- Improved startup output to show configured authentication parameter names when enabled
2425
- Updated help text to reflect new options
2526

2627
### Fixed
28+
2729
- Better URL normalization for various input formats
2830

2931
## [0.1.0] - 2025-11-06
3032

3133
### Added
34+
3235
- Initial release
3336
- Basic reverse proxy functionality
3437
- Optional authentication via URL parameter or header

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,23 @@ A simple, lightweight reverse proxy with URL parameter or header authentication.
1212

1313
## Installation
1414

15+
### Quick Install (Recommended)
16+
17+
Install with a single command using our installation script:
18+
19+
```bash
20+
curl -fsSL https://raw.githubusercontent.com/talkincode/apxy/main/install.sh | bash
21+
```
22+
23+
This will automatically detect your OS and architecture, download the latest release, and install it to `/usr/local/bin`.
24+
1525
### Via Cargo
1626

1727
```bash
1828
cargo install apxy
1929
```
2030

21-
### Via curl (Quick Install)
31+
### Manual Installation via curl
2232

2333
```bash
2434
# Linux/macOS ARM64

src/main.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,27 @@ fn full<T: Into<Bytes>>(chunk: T) -> BoxBody {
4343
/// Normalize target URL from various shorthand formats
4444
fn normalize_target(target: &str) -> String {
4545
let target = target.trim();
46-
46+
4747
// If it already starts with http:// or https://, return as is
4848
if target.starts_with("http://") || target.starts_with("https://") {
4949
return target.to_string();
5050
}
51-
51+
5252
// If it's just a port number (e.g., "3000")
5353
if target.parse::<u16>().is_ok() {
5454
return format!("http://localhost:{}", target);
5555
}
56-
56+
5757
// If it starts with : (e.g., ":3000")
5858
if target.starts_with(':') {
5959
return format!("http://localhost{}", target);
6060
}
61-
61+
6262
// If it's localhost:port or 127.0.0.1:port format (no protocol)
6363
if !target.contains("://") {
6464
return format!("http://{}", target);
6565
}
66-
66+
6767
// Default: assume it's meant to be http
6868
format!("http://{}", target)
6969
}
@@ -114,7 +114,7 @@ async fn handle_request(
114114
.path_and_query()
115115
.map(|pq| pq.as_str())
116116
.unwrap_or("/");
117-
117+
118118
let target_url = format!("{}{}", target.trim_end_matches('/'), path_and_query);
119119

120120
// Create client request
@@ -124,9 +124,7 @@ async fn handle_request(
124124
let (parts, body) = req.into_parts();
125125
let body_bytes = body.collect().await?.to_bytes();
126126

127-
let mut proxy_req = Request::builder()
128-
.method(parts.method)
129-
.uri(&target_url);
127+
let mut proxy_req = Request::builder().method(parts.method).uri(&target_url);
130128

131129
// Copy headers
132130
for (key, value) in parts.headers.iter() {
@@ -142,12 +140,12 @@ async fn handle_request(
142140
Ok(response) => {
143141
let (parts, body) = response.into_parts();
144142
let body_bytes = body.collect().await?.to_bytes();
145-
143+
146144
let mut builder = Response::builder().status(parts.status);
147145
for (key, value) in parts.headers.iter() {
148146
builder = builder.header(key, value);
149147
}
150-
148+
151149
Ok(builder.body(full(body_bytes)).unwrap())
152150
}
153151
Err(_) => Ok(Response::builder()
@@ -160,7 +158,7 @@ async fn handle_request(
160158
#[tokio::main]
161159
async fn main() -> Result<(), Box<dyn std::error::Error>> {
162160
let args = Args::parse();
163-
161+
164162
// Normalize target URL to support shorthand formats
165163
let target = normalize_target(&args.target);
166164

0 commit comments

Comments
 (0)