HttpServer
resource creates an HTTP API endpoint for your Ditto database, allowing any HTTP client (including web browsers) to query and manipulate data using standard REST methods. This enables integration with systems that cannot use the Ditto SDK directly.
Basic Configuration
Required Fields
Field | Type | Description |
---|---|---|
resource_type | string | Must be "HttpServer" |
db_id | string | The database ID (UUIDv4 format) to expose via HTTP. Must match an existing DittoDatabase resource |
listen_addr | string | Address and port to listen on (format: "host:port" ). |
http_api | boolean/object | Enable HTTP API endpoints. Use true to enable all, false to disable, or an object for fine-grained control |
Optional Fields
Field | Type | Default | Description |
---|---|---|---|
base_path | string/null | Uses db_id | URL path prefix for the API endpoints. Must be a valid URI path segment |
Listen Address Configuration
Thelisten_addr
field specifies where the HTTP server listens for connections:
- IPv4 localhost:
"127.0.0.1:PORT"
or"localhost:PORT"
- IPv6 localhost:
"[::1]:PORT"
or"[::]:PORT"
HTTP API Configuration
Thehttp_api
field controls which endpoints are enabled:
Simple Configuration
Enable or disable all endpoints:Fine-Grained Configuration
Control individual endpoints:Field | Type | Default | Description |
---|---|---|---|
enable_execute | boolean | true | Enable the /execute endpoint for DQL queries |
enable_healthcheck | boolean | false | Enable the health check endpoint |
API Endpoints
Execute Endpoint
Path:POST /<base_path>/execute
Execute DQL queries against the database.
Request body:
- Success (200): Query results in JSON format
- Error (4xx/5xx): Error details with appropriate HTTP status code
Health Check Endpoint
Path:GET /<base_path>
Simple health check that returns HTTP 200 if the server is running.
Complete Examples
Basic HTTP Server
http://127.0.0.1:8080/12345678-1234-4123-1234-123456789012/execute
Custom Base Path
http://localhost:3000/my_server/execute
Multiple HTTP Servers
Expose multiple databases on different ports:Health Check Only Server
Minimal configuration for monitoring:http://127.0.0.1:9090/health
Using the HTTP API
Query Execution Example
Health Check Example
Security Considerations
While Ditto Edge Server is in private preview, no deployments should be considered secure. Use is for development purposes only.Important Notes
- Database ID Matching: The
db_id
must exactly match a DittoDatabase resource in your configuration - Port Conflicts: Ensure each HttpServer uses a unique port to avoid binding conflicts
- Restart Required: Changes to HTTP server configuration require Edge Server restart
- IPv6 Support: Use bracketed notation for IPv6 addresses (e.g.,
"[::1]:8080"
)