Quick Start
This guide will help you create your first Rust Edge Gateway endpoint in under 5 minutes.
Prerequisites
- Rust Edge Gateway running (either locally via Docker or deployed)
- Access to the Admin UI
Step 1: Access the Admin UI
Navigate to your gateway's admin interface:
- Local Development:
http://localhost:9081/admin/ - Production:
https://rust-edge-gateway.yourdomain.com/admin/
Step 2: Create an Endpoint
- Click "Create Endpoint" or the + button
- Fill in the endpoint details:
| Field | Example Value | Description |
|---|---|---|
| Name | hello-world | Unique identifier for your endpoint |
| Path | /hello | The URL path to match |
| Method | GET | HTTP method (GET, POST, PUT, DELETE, etc.) |
| Domain | * | Domain to match (or * for all) |
- Click Save
Step 3: Write Handler Code
In the code editor, replace the default code with:
#![allow(unused)] fn main() { use rust_edge_gateway_sdk::prelude::*; fn handle(req: Request) -> Response { Response::ok(json!({ "message": "Hello from Rust Edge Gateway!", "path": req.path, "method": req.method, "timestamp": chrono::Utc::now().to_rfc3339(), })) } handler_loop!(handle); }
Step 4: Compile
Click the "Compile" button. The gateway will:
- Generate a Cargo project with your code
- Compile it to a native binary
- Report success or any compilation errors
You should see a success message like:
✓ Compiled successfully in 2.3s
Step 5: Start the Endpoint
Click "Start" to activate the endpoint. The status should change to Running.
Step 6: Test Your Endpoint
Make a request to your endpoint:
curl http://localhost:9080/hello
You should receive:
{
"message": "Hello from Rust Edge Gateway!",
"path": "/hello",
"method": "GET",
"timestamp": "2024-01-15T10:30:00.000Z"
}
What's Next?
- Your First Handler - Deeper dive into handler structure
- Handler Lifecycle - Understand compilation and execution
- Request API - Access headers, body, parameters
- Response API - Build JSON, text, and custom responses
- Examples - More code examples
Troubleshooting
Compilation Errors
Check the error message for:
- Missing dependencies (add to your handler's
usestatements) - Syntax errors (Rust compiler messages are helpful!)
- Type mismatches
Endpoint Not Responding
- Check the endpoint is in Running status
- Verify the path matches exactly (paths are case-sensitive)
- Check the method matches your request
- View endpoint logs in the admin UI
Handler Crashes
View the logs to see panic messages or error output. Common causes:
- Unwrapping
NoneorErrvalues - Stack overflow from deep recursion
- Accessing invalid JSON fields