pub struct AdapterOptions {Show 14 fields
pub host: String,
pub port: String,
pub readiness_check_port: String,
pub readiness_check_path: String,
pub readiness_check_protocol: Protocol,
pub readiness_check_min_unhealthy_status: u16,
pub readiness_check_healthy_status: Vec<u16>,
pub base_path: Option<String>,
pub pass_through_path: String,
pub async_init: bool,
pub compression: bool,
pub invoke_mode: LambdaInvokeMode,
pub authorization_source: Option<String>,
pub error_status_codes: Option<Vec<u16>>,
}Expand description
Configuration options for the Lambda Web Adapter.
This struct holds all configuration parameters for the adapter. It can be constructed
manually or using Default::default() which reads values from environment variables.
§Environment Variables
When using Default::default(), the following environment variables are read:
| Field | Environment Variable | Fallback | Default |
|---|---|---|---|
host | AWS_LWA_HOST | HOST | 127.0.0.1 |
port | AWS_LWA_PORT | PORT | 8080 |
readiness_check_port | AWS_LWA_READINESS_CHECK_PORT | READINESS_CHECK_PORT | Same as port |
readiness_check_path | AWS_LWA_READINESS_CHECK_PATH | READINESS_CHECK_PATH | / |
readiness_check_protocol | AWS_LWA_READINESS_CHECK_PROTOCOL | READINESS_CHECK_PROTOCOL | HTTP |
readiness_check_healthy_status | AWS_LWA_READINESS_CHECK_HEALTHY_STATUS | - | 100-499 |
base_path | AWS_LWA_REMOVE_BASE_PATH | REMOVE_BASE_PATH | None |
async_init | AWS_LWA_ASYNC_INIT | ASYNC_INIT | false |
compression | AWS_LWA_ENABLE_COMPRESSION | - | false |
invoke_mode | AWS_LWA_INVOKE_MODE | - | buffered |
§Deprecated Environment Variables
The non-prefixed environment variables (e.g., HOST, READINESS_CHECK_PORT) are deprecated
and will be removed in version 2.0. Please use the AWS_LWA_ prefixed versions.
Note: PORT is not deprecated and remains a supported fallback for AWS_LWA_PORT.
§Examples
use lambda_web_adapter::{AdapterOptions, Protocol, LambdaInvokeMode};
// Use defaults from environment variables
let options = AdapterOptions::default();
// Or configure manually
let options = AdapterOptions {
host: "127.0.0.1".to_string(),
port: "3000".to_string(),
readiness_check_path: "/health".to_string(),
readiness_check_protocol: Protocol::Http,
invoke_mode: LambdaInvokeMode::ResponseStream,
..Default::default()
};Fields§
§host: StringHost address where the web application is listening.
Default: 127.0.0.1
port: StringPort where the web application is listening.
Falls back to PORT env var, then default 8080.
readiness_check_port: StringPort to use for readiness checks. Defaults to the same as port.
Useful when your application exposes health checks on a different port.
readiness_check_path: StringHTTP path for readiness checks.
Default: /
readiness_check_protocol: ProtocolProtocol to use for readiness checks.
Default: Protocol::Http
readiness_check_min_unhealthy_status: u16Deprecated: Use readiness_check_healthy_status instead.
Minimum HTTP status code considered unhealthy.
readiness_check_healthy_status: Vec<u16>List of HTTP status codes considered healthy for readiness checks.
Can be configured via AWS_LWA_READINESS_CHECK_HEALTHY_STATUS using:
- Single codes:
200,201,204 - Ranges:
200-399 - Mixed:
200-299,301,302,400-499
Default: 100-499 (all 1xx, 2xx, 3xx, and 4xx status codes)
base_path: Option<String>Base path to strip from incoming requests.
Useful when your Lambda is behind an API Gateway with a stage name or custom path that your application doesn’t expect.
Example: If set to /prod, a request to /prod/api/users becomes /api/users.
pass_through_path: StringPath to forward pass-through events to.
Default: /events
async_init: boolEnable async initialization mode.
When true, the adapter will cancel readiness checks after ~9.8 seconds
to avoid Lambda’s 10-second init timeout. The application can continue
booting in the background and will be checked again on the first request.
Default: false
compression: boolEnable response compression.
When true, responses will be compressed using gzip, deflate, or brotli
based on the Accept-Encoding header.
Note: Compression is not supported with response streaming
(LambdaInvokeMode::ResponseStream). If both are enabled, compression
will be automatically disabled with a warning.
Default: false
invoke_mode: LambdaInvokeModeLambda invoke mode for response handling.
Default: LambdaInvokeMode::Buffered
Header name to copy to the Authorization header.
Useful when your authorization token comes in a custom header
(e.g., from API Gateway authorizers) and your application expects
it in the standard Authorization header.
error_status_codes: Option<Vec<u16>>HTTP status codes that should trigger a Lambda error response.
When the web application returns one of these status codes, the adapter will return an error to Lambda instead of the response. This can be useful for triggering Lambda retry behavior.