Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

  1. Click "Create Endpoint" or the + button
  2. Fill in the endpoint details:
FieldExample ValueDescription
Namehello-worldUnique identifier for your endpoint
Path/helloThe URL path to match
MethodGETHTTP method (GET, POST, PUT, DELETE, etc.)
Domain*Domain to match (or * for all)
  1. 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::*;

#[handler]
pub async fn handle(ctx: &Context, req: Request) -> Response {
    Response::ok(json!({
        "message": "Hello from Rust Edge Gateway!",
        "path": req.path,
        "method": req.method,
    }))
}
}

Step 4: Compile

Click the "Compile" button. The gateway will:

  1. Generate a Cargo project with your code
  2. Compile it to a dynamic library (.so/.dll)
  3. Report success or any compilation errors

You should see a success message like:

✓ Compiled successfully in 2.3s

Step 5: Deploy the Endpoint

Click "Deploy" to load the handler. The status should change to Loaded.

The handler is now active and receiving requests - no separate "start" step needed!

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"
}

What's Next?

Troubleshooting

Compilation Errors

Check the error message for:

  • Missing dependencies (add to your handler's use statements)
  • Syntax errors (Rust compiler messages are helpful!)
  • Type mismatches
  • Missing #[handler] attribute

Endpoint Not Responding

  1. Check the endpoint is in Loaded status
  2. Verify the path matches exactly (paths are case-sensitive)
  3. Check the method matches your request
  4. View endpoint logs in the admin UI

Handler Errors

View the logs to see panic messages or error output. Common causes:

  • Unwrapping None or Err values
  • Accessing invalid JSON fields
  • Service actor communication errors