This repository is a small Rust reverse proxy server (Axum + Reqwest). Use this file as the primary guidance for automated agents working here.
- Keep changes minimal and idiomatic to this codebase.
- Prefer explicit, readable code over cleverness.
- Avoid adding dependencies unless necessary; keep Cargo.toml lean.
- No Cursor rules found in
.cursor/rules/or.cursorrules. - No Copilot rules found in
.github/copilot-instructions.md.
If new rules are added later, incorporate them here.
Common commands (run from repo root):
# Build (debug)
cargo build
# Build (release)
cargo build --release
# Run (needs config file)
cargo run -- -c /path/to/config.toml
# Format (Rust standard formatting)
cargo fmt
# Lint (Clippy)
cargo clippy --all-targets --all-features -- -D warnings
# Test suite
cargo testRunning a single test (if/when tests exist):
# By test name substring
cargo test <test_name_substring>
# Integration test file
cargo test --test <test_file_name_without_rs>
# Unit tests in a specific module
cargo test <module_path>::<test_name>If tests are added later, update this section with project-specific commands.
src/main.rs: entrypoint and logging setup.src/config.rs: config file parsing/validation and CLI args.src/run.rs: server setup and Axum routing composition.src/proxy.rs: proxy routing logic and request forwarding.src/error.rs: minimal error type and Result alias.
- Use grouped, sorted imports similar to existing files:
- std imports first
- third-party imports next
- crate imports last
- Prefer explicit
useof types/modules used in a file. - Avoid wildcard imports except when already common in Axum patterns.
- Run
cargo fmtafter edits. - Keep line lengths reasonable; prefer line breaks over horizontal scrolling.
- Use Rust 2024 edition conventions; do not introduce deprecated patterns.
- Modules:
snake_case(files already follow this). - Types/structs/enums:
PascalCase. - Functions/variables:
snake_case. - Constants:
SCREAMING_SNAKE_CASE. - Avoid abbreviations unless already used in the codebase (
cfg,req).
- Favor concrete types for public APIs; avoid unnecessary generics.
- Prefer borrowing (
&str,&T) unless ownership is needed. - Clone only when necessary; e.g.,
reqwest::Clientis cheap to clone. - Use
OptionandResultto model fallible or optional behavior.
- Use the crate
Result<T>alias (src/error.rs). - Convert errors into
Error::AnyErrorvia?orinto(). - Provide clear, actionable error messages (see config validation).
- For HTTP errors, use appropriate
StatusCodevalues and readable bodies.
- Use
tracingfor diagnostics (info,debug, etc.). - Respect
RUST_LOG_MAXbehavior insrc/main.rs. - Avoid logging sensitive data (auth headers, tokens).
- Preserve existing header forwarding rules unless intentionally changing behavior.
- When adding headers, be explicit about reasons and scope.
- Keep proxy path rewrites consistent with
source_path->dest_path. - Do not enable WebSocket behavior unless explicitly requested.
- Config is TOML (
config.toml) and required to run. Config::buildperforms minimal validation; maintain or extend as needed.- CLI uses
clapderive; add new flags inArgswith clear doc comments.
- If you add tests, prefer
#[tokio::test]for async code. - Unit tests can live next to modules; integration tests in
tests/. - Keep tests deterministic; mock external HTTP calls where possible.
- Prefer standard library and existing dependencies first.
- New deps require justification and should be minimal in scope.
- If adding a dev-only tool, use
[dev-dependencies].
- Do not modify
config-example.tomlunless required by a feature. - Avoid changing behavior unrelated to the requested task.
- If a change impacts runtime behavior (routing, headers, auth), document it.
- There is no CI config or task runner; use cargo commands directly.
- This project is intentionally simple; keep it that way.