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 binaries and run as isolated worker processes, providing:
- π Native Performance - Handlers compile to optimized native code
- π Isolation - Each handler runs in its own process
- π Hot Reload - Update handlers without restarting the gateway
- π οΈ Simple SDK - Easy-to-use Request/Response API
- π¦ Service Integration - Connect to databases, Redis, and more
How It Works
βββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Client ββββββΆβ Edge Gateway ββββββΆβ Your Handler β
β (Browser, β β (Routes & β β (Compiled β
β API, etc) βββββββ Manages) βββββββ Rust Binary) β
βββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββ
β Services β
β (DB, Redis, β
β MinIO, etc) β
βββββββββββββββββ
- Gateway receives request - The gateway matches the incoming request to an endpoint
- Handler is invoked - The compiled handler binary receives the request via IPC
- Handler processes - Your code runs, optionally using injected services
- Response returned - The handler sends the response back through 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 test
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::*; fn handle(req: Request) -> Response { Response::ok(json!({ "message": "Hello, World!", "path": req.path, "method": req.method, })) } handler_loop!(handle); }
The SDK provides:
- 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, Redis, and other service integrations
Architecture
Rust Edge Gateway uses a worker process model:
- Main Gateway - Axum-based HTTP server handling routing
- Worker Processes - Your compiled handlers as standalone binaries
- IPC Protocol - Length-prefixed JSON over stdin/stdout
- Service Connectors - Pooled connections to backends (DB, Redis, etc.)
This architecture provides:
- Security - Handlers can't directly access the gateway's memory
- Stability - A crashed handler doesn't bring down the gateway
- Scalability - Multiple worker instances can handle concurrent requests