Rust Edge Gateway
Rust Edge Gateway is a high-performance API gateway that lets you write request handlers in Rust. Your handlers are compiled to native dynamic libraries and loaded directly into the gateway process, providing:
- π Native Performance - Handlers compile to optimized native code (.so/.dll)
- β‘ Zero-Copy Execution - Direct function calls, no serialization overhead
- π Hot Reload - Swap handlers without restarting the gateway
- π Actor-Based Services - Database, cache, and storage via message-passing
- π Graceful Draining - Zero-downtime deployments with request draining
- π οΈ Simple SDK - Easy-to-use Context, Request, and Response API
How It Works
βββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Client ββββββΆβ Edge Gateway ββββββΆβ Your Handler β
β (Browser, β β (Routes & β β (Dynamic β
β API, etc) βββββββ Manages) βββββββ Library .so) β
βββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββ
β Service Actorsβ
β (DB, Cache, β
β Storage) β
βββββββββββββββββ
- Gateway receives request - The gateway matches the incoming request to an endpoint
- Handler is invoked - The compiled handler library is called directly via function pointer
- Handler processes - Your code runs with access to the Context API and Service Actors
- Response returned - The handler returns a Response directly to the gateway
Getting Started
The fastest way to get started is to:
- Access the Admin UI at
/admin/ - Create a new endpoint
- Write your handler code
- Compile and deploy
See the Quick Start guide for detailed instructions.
SDK Overview
Your handler code uses the rust-edge-gateway-sdk crate:
#![allow(unused)] fn main() { use rust_edge_gateway_sdk::prelude::*; #[handler] pub async fn handle(ctx: &Context, req: Request) -> Response { Response::ok(json!({ "message": "Hello, World!", "path": req.path, "method": req.method, })) } }
The SDK provides:
- Context - Access to Service Actors (database, cache, storage)
- Request - Access HTTP method, path, headers, body, query params
- Response - Build HTTP responses with JSON, text, or custom content
- HandlerError - Structured error handling with HTTP status codes
- Services - Database, cache, and storage service actors
Architecture
Rust Edge Gateway uses a dynamic library loading model with actor-based services:
- Main Gateway - Axum-based HTTP server handling routing
- Handler Registry - Manages loaded handler libraries with hot-swap support
- Dynamic Libraries - Your compiled handlers as
.so(Linux),.dll(Windows), or.dylib(macOS) - Service Actors - Message-passing based services for database, cache, and storage
- Graceful Draining - Old handlers complete in-flight requests during updates
This architecture provides:
- Performance - Direct function calls with zero serialization overhead
- Hot Swapping - Replace handlers without gateway restart
- Zero Downtime - Graceful draining ensures no dropped requests during updates
- Scalability - Async handlers with Tokio runtime for high concurrency