π pingora_web
π₯ Fast setup | Built on Pingora | Beginner friendly π¦
A web framework built on Cloudflare's Pingora proxy infrastructure, designed to be fast, reliable, and easy to use.
β¨ Features
Core Features
- π£οΈ Path routing with parameters (
/users/{id}) - π§ Middleware system with onion model (like Express.js)
- π·οΈ Request ID tracking (automatic
x-request-idheader) - π Structured logging with tracing integration
- π¦ JSON support with automatic serialization
- π Static file serving with MIME type detection
- π Streaming responses for large data transfers
Built on Pingora
- β‘ High performance - leverages Cloudflare's production-tested proxy
- ποΈ HTTP compression - built-in gzip support
- π‘οΈ Request limits - timeout, body size, and header constraints
- π¨ Panic recovery - automatic error handling
- π HTTP/1.1 & HTTP/2 support via Pingora
π Quick Start
1. Create a new project
&&
2. Add dependencies to Cargo.toml
Minimal setup (Hello World):
[]
= "0.1"
Full setup (with JSON, logging, etc.):
[]
= "0.1"
= { = "1.0", = ["derive"] }
= "1.0"
= { = "0.3", = ["env-filter"] }
3. Hello World (5 lines - like Express/Gin)
use ;
4. With Parameters (beginner-friendly)
use ;
5. Full-featured example
use async_trait;
use ;
use Arc;
;
6. Run the server
Visit http://localhost:8080/ or http://localhost:8080/hi/world to see it working!
Advanced usage (for complex setups)
If you need more control over the server configuration:
use async_trait;
use ;
use Server;
use Arc;
;
π Documentation
- Architecture & Design Philosophy - Detailed explanation of design decisions and architectural patterns
π Examples
JSON API (ζ ΈεΏεθ½)
Building REST APIs is the primary use case:
use ;
use ;
HTTP Modules (Built-in Pingora Features)
pingora_web integrates Pingora's high-performance HTTP modules for advanced functionality:
use ;
Available HTTP Modules
- ResponseCompressionBuilder: High-performance gzip compression
- Supports compression levels 1-9
- Automatic client detection via Accept-Encoding
- Streaming compression for large responses
- Optimized for production use at Cloudflare scale
Compression Example
// Enable compression with level 6 (recommended)
app.add_http_module;
// Test with curl:
// curl -H "Accept-Encoding: gzip" -v http://localhost:8080/large-response
// Response will include: Content-Encoding: gzip
Static File Serving (Optional)
use ServeDir;
Development
Prerequisites
- Rust 1.75 or later
- Git
Building
Testing
Code Quality
This project uses several tools to maintain code quality:
# Format code
# Lint code
# Security audit
Running Examples
Then visit:
http://localhost:8080/- Basic responsehttp://localhost:8080/foo- Static routehttp://localhost:8080/hi/yourname- Route with parametershttp://localhost:8080/json- JSON responsehttp://localhost:8080/assets/README.md- Static file serving
π― Use Cases
Perfect for:
- APIs and microservices requiring high throughput
- Edge applications with low latency requirements
- Proxy servers and load balancers
- Real-time applications with many concurrent connections
Release Process
This project uses automated releases through GitHub Actions:
- Create a new tag:
git tag v0.1.1 && git push origin v0.1.1 - GitHub Actions will:
- Run all tests and quality checks
- Create a GitHub release with auto-generated notes
- Publish the crate to crates.io
- Verify the publication
Setting Up Automated Releases
To enable automated publishing to crates.io:
- Get your API token from crates.io/me
- Add it as a repository secret named
CARGO_REGISTRY_TOKEN - Push a version tag to trigger the release workflow
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and quality checks
- Submit a pull request
All pull requests are automatically tested with GitHub Actions.
License
Dual-licensed under either:
- MIT
- Apache-2.0
at your option.
Source repository: https://github.com/pingora-web/pingora_web Documentation: https://docs.rs/pingora_web