| Crates.io | httpcan |
| lib.rs | httpcan |
| version | 0.5.2 |
| created_at | 2025-09-23 17:57:27.27805+00 |
| updated_at | 2025-10-17 17:33:47.21274+00 |
| description | A simple HTTP Request & Response Service, with httpbin compatibility |
| homepage | https://github.com/seedvector/httpcan |
| repository | https://github.com/seedvector/httpcan |
| max_upload_size | |
| id | 1851860 |
| size | 3,435,617 |
A simple, high‑performance HTTP request & response service built with Rust and Actix Web. Fully compatible with httpbin.org, with modern streaming and AI‑friendly enhancements.
Quick Links: Quick Start · Installation · Configuration · Examples · OpenAPI & Web UI · API Reference · Library · Development · License
Choose one way to run:
# Docker (recommended)
docker run -p 8080:8080 ghcr.io/seedvector/httpcan:latest
curl http://localhost:8080/get
# Cargo
cargo install httpcan
httpcan
curl http://localhost:8080/get
# Latest image
docker run -p 8080:8080 ghcr.io/seedvector/httpcan:latest
# Custom port
docker run -p 3000:3000 ghcr.io/seedvector/httpcan:latest --port 3000
# Header filtering
docker run -p 8080:8080 ghcr.io/seedvector/httpcan:latest --exclude-headers "foo, x-bar-*"
# Install globally
cargo install httpcan
# Run
httpcan
httpcan --port 3000
httpcan --exclude-headers "foo, x-bar-*"
httpcan --port 3000 --no-current-server --exclude-headers "x-forwarded-*,cf-*"
git clone https://github.com/seedvector/httpcan.git
cd httpcan
# Default (8080)
cargo run
# Custom port
cargo run -- --port 3000
# Release build
cargo build --release
./target/release/httpcan --port 8080
CLI flags:
| Option | Description | Default | Example |
|---|---|---|---|
-p, --port <PORT> |
Port number to listen on | 8080 |
--port 3000 |
--no-current-server |
Do not add current server to OpenAPI servers list |
false |
--no-current-server |
--exclude-headers <HEADERS> |
Exclude headers in responses; comma‑separated; supports wildcard suffix (e.g. x-bar-*) |
"" |
--exclude-headers "x-forwarded-*,cf-*,server" |
-h, --help |
Print help information | --help |
|
-V, --version |
Print version | --version |
Notes:
-p host:container mapping matches your --port if you override it.# Basic GET
curl http://localhost:8080/get
# POST with JSON
curl -X POST http://localhost:8080/post \
-H "Content-Type: application/json" \
-d '{"key":"value"}'
# Basic auth
curl -u username:password http://localhost:8080/basic-auth/username/password
# Username only (empty password) — enhanced
curl -u username: http://localhost:8080/basic-auth/username
# Specific status
curl http://localhost:8080/status/418
# Random from list
curl http://localhost:8080/status/200,404,500
# Redirect to a URL (supports form/json)
curl -X POST http://localhost:8080/redirect-to -d "url=https://example.com"
curl -H "Accept-Encoding: gzip" http://localhost:8080/gzip
curl http://localhost:8080/json
curl http://localhost:8080/xml
# SSE
curl http://localhost:8080/sse?count=3&format=simple
curl http://localhost:8080/sse/5?format=openai&delay=2000
# NDJSON
curl http://localhost:8080/ndjson?count=3&format=simple
curl http://localhost:8080/ndjson/5?format=ollama&model=llama3&delay=1500
curl http://localhost:8080/cookies
curl http://localhost:8080/headers
curl http://localhost:8080/ip
GET /openapi.json/ in a browser; renders HTML or JSON based on Accept headerGET /get, POST /post, PUT /put, PATCH /patch, DELETE /delete/anything, /anything/{anything} (supports multiple methods)robots.txt, encoding/utf8, gzip/deflate/brotliuuid, bytes, stream, range, links, delay, dripredirect, relative-redirect, absolute-redirect, redirect-toheaders, ip, user-agentcache, etag, response-headerscookies CRUDimage, image/png, image/jpeg, image/webp, image/svg/status/{codes} (single or comma‑separated)For the full, up‑to‑date list and schemas, consult the OpenAPI spec.
/echo reflects request body and headers (multi‑method)/jwt-bearerAccept > request Content-Type > default; supports custom bodies via query/bodyPOST /redirect-to supports application/x-www-form-urlencoded, multipart/form-data, application/jsoncount, delay, and AI formats (OpenAI/Ollama)Add dependency:
[dependencies]
httpcan = "0.5"
Embed server:
use httpcan::HttpCanServer;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
HttpCanServer::new()
.port(3000)
.host("127.0.0.1")
.exclude_header("foo, x-bar-*")
.run()
.await?;
Ok(())
}
More examples and advanced config: see LIBRARY_USAGE.md.
# Run checks
cargo fmt --all
cargo clippy --all -- -D warnings
cargo test
# Run locally
cargo run -- --port 8080
Contributions are welcome! Please open issues/PRs for discussion.
MIT — see LICENSE.