Skip to main content
The HTTP module (RestApiModule) allows you to expose iii functions as HTTP/REST endpoints, making them accessible via standard HTTP requests.

Configuration

Configure the HTTP module in config.yaml:
config.yaml

Configuration Options

number
default:"3111"
HTTP server port
string
default:"127.0.0.1"
Bind address for the HTTP server
number
default:"30000"
Request timeout in milliseconds
number
default:"1024"
Maximum concurrent HTTP requests
object
CORS configuration for cross-origin requests
  • allowed_origins: Array of allowed origins (use '*' for all)
  • allowed_methods: Array of allowed HTTP methods

Creating HTTP Endpoints

Define HTTP triggers in your function configuration:
index.ts

Request Input Format

HTTP triggers receive input in this format:

Example: Path Parameters

Example: Query Parameters

Example: Request Body

HTTP Methods

Supported HTTP methods:
  • GET - Retrieve resources
  • POST - Create resources
  • PUT - Update/replace resources
  • DELETE - Delete resources
  • PATCH - Partial updates
  • OPTIONS - CORS preflight

Response Handling

Success Response

Return data directly from your function:
HTTP response:

Error Response

Throw errors to return error responses:

Path Patterns

The HTTP module supports dynamic path parameters:
Access parameters:

CORS Configuration

Allow All Origins (Development)

Specific Origins (Production)

Middleware & Timeout

The HTTP module applies these layers automatically:
  1. CORS - Cross-origin resource sharing
  2. Timeout - Request timeout (configurable)
  3. Concurrency Limit - Max concurrent requests

Example: Complete API

index.ts

Testing Endpoints

Source Code Reference

  • Module: src/modules/rest_api/api_core.rs:69
  • Router: src/modules/rest_api/hot_router.rs
  • Trigger registration: src/modules/rest_api/api_core.rs:100