Skip to main content

AdapterOptions

Struct AdapterOptions 

Source
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:

FieldEnvironment VariableFallbackDefault
hostAWS_LWA_HOSTHOST127.0.0.1
portAWS_LWA_PORTPORT8080
readiness_check_portAWS_LWA_READINESS_CHECK_PORTREADINESS_CHECK_PORTSame as port
readiness_check_pathAWS_LWA_READINESS_CHECK_PATHREADINESS_CHECK_PATH/
readiness_check_protocolAWS_LWA_READINESS_CHECK_PROTOCOLREADINESS_CHECK_PROTOCOLHTTP
readiness_check_healthy_statusAWS_LWA_READINESS_CHECK_HEALTHY_STATUS-100-499
base_pathAWS_LWA_REMOVE_BASE_PATHREMOVE_BASE_PATHNone
async_initAWS_LWA_ASYNC_INITASYNC_INITfalse
compressionAWS_LWA_ENABLE_COMPRESSION-false
invoke_modeAWS_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: String

Host address where the web application is listening. Default: 127.0.0.1

§port: String

Port where the web application is listening. Falls back to PORT env var, then default 8080.

§readiness_check_port: String

Port 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: String

HTTP path for readiness checks. Default: /

§readiness_check_protocol: Protocol

Protocol to use for readiness checks. Default: Protocol::Http

§readiness_check_min_unhealthy_status: u16
👎Deprecated since 1.0.0: Use readiness_check_healthy_status instead

Deprecated: 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: String

Path to forward pass-through events to. Default: /events

§async_init: bool

Enable 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: bool

Enable 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: LambdaInvokeMode

Lambda invoke mode for response handling. Default: LambdaInvokeMode::Buffered

§authorization_source: Option<String>

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.

Trait Implementations§

Source§

impl Default for AdapterOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more