Skip to content

Commit 0855c5b

Browse files
committed
add comment of flow
1 parent d33d164 commit 0855c5b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bottlecap/src/lwa/proxy.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,25 @@ fn parse_env_addresses() -> Option<(SocketAddr, Uri)> {
133133
}
134134
}
135135

136+
// Example of flow
137+
// Starting up proxy
138+
// LWA: proxy enabled with proxy URI: 127.0.0.1:9002 and AWS runtime: http://127.0.0.1:9001/
139+
// Extension is ready, blocking on GET /invocation/next. Intercepting it in theis LWA proxy
140+
// LWA: Intercepted request: Parts { method: GET, uri: /2018-06-01/runtime/invocation/next, version: HTTP/1.1, headers: {"user-agent": "aws-lambda-rust/aws-lambda-adapter/0.9.0", "host": "127.0.0.1:9002"} }
141+
// LWA: Intercepted request body: b""
142+
// AWS lambda service returns from GET /invocation/next with the incoming invocation. LWA wraps it into the body. LWA proxy intercepts it
143+
// LWA: Intercepted resp: Parts { status: 200, version: HTTP/1.1, headers: {"content-type": "application/json", "lambda-runtime-aws-request-id": "8442603f-da10-42d2-bf58-c33a31978aad", "lambda-runtime-deadline-ms": "1741965555094", "lambda-runtime-invoked-function-arn": "arn:aws:lambda:us-east-1:425362996713:function:ag-lwa-stack-lambda", "lambda-runtime-trace-id": "Root=1-67d448e8-3ae320be0e2cdf2f53ccdaba;Lineage=1:73f724a8:0", "date": "Fri, 14 Mar 2025 15:19:06 GMT", "content-length": "927"} }
144+
// LWA: Intercepted resp body: b"{\"version\":\"2.0\",\"routeKey\":\"$default\",\"rawPath\":\"/\",\"rawQueryString\":\"\",\"headers\":{\"x-amzn-tls-cipher-suite\":\"TLS_AES_128_GCM_SHA256\",\"x-amzn-tls-version\":\"TLSv1.3\",\"x-amzn-trace-id\":\"Root=1-67d448e8-3ae320be0e2cdf2f53ccdaba\",\"x-forwarded-proto\":\"https\",\"host\":\"e366vgzulqwityxor4e6nfkdam0axzew.lambda-url.us-east-1.on.aws\",\"x-forwarded-port\":\"443\",\"x-forwarded-for\":\"70.107.97.101\",\"accept\":\"*/*\",\"user-agent\":\"curl/7.81.0\"},\"requestContext\":{\"accountId\":\"anonymous\",\"apiId\":\"e366vgzulqwityxor4e6nfkdam0axzew\",\"domainName\":\"e366vgzulqwityxor4e6nfkdam0axzew.lambda-url.us-east-1.on.aws\",\"domainPrefix\":\"e366vgzulqwityxor4e6nfkdam0axzew\",\"http\":{\"method\":\"GET\",\"path\":\"/\",\"protocol\":\"HTTP/1.1\",\"sourceIp\":\"70.107.97.101\",\"userAgent\":\"curl/7.81.0\"},\"requestId\":\"8442603f-da10-42d2-bf58-c33a31978aad\",\"routeKey\":\"$default\",\"stage\":\"$default\",\"time\":\"14/Mar/2025:15:19:04 +0000\",\"timeEpoch\":1741965544908},\"isBase64Encoded\":false}"
145+
// Lambda Runtime processes the request and when it's done, POST to runtime/invocation/REQ_ID/response. The body has the response. LWA proxy intercepts it
146+
// LWA: Intercepted request: Parts { method: POST, uri: /2018-06-01/runtime/invocation/8442603f-da10-42d2-bf58-c33a31978aad/response, version: HTTP/1.1, headers: {"user-agent": "aws-lambda-rust/aws-lambda-adapter/0.9.0", "host": "127.0.0.1:9002", "content-length": "238"} }
147+
// LWA: Intercepted request body: b"{\"statusCode\":200,\"headers\":{\"date\":\"Fri, 14 Mar 2025 15:19:06 GMT\",\"content-length\":\"34\",\"content-type\":\"text/html; charset=utf-8\"},\"multiValueHeaders\":{},\"body\":\"<h1>Hello, Website with span!<h1>\\n\",\"isBase64Encoded\":false,\"cookies\":[]}
148+
// AWS Lambda service responds to the POST with a 202. LWA proxy intercepts it
149+
// LWA: Intercepted resp: Parts { status: 202, version: HTTP/1.1, headers: {"content-type": "application/json", "date": "Fri, 14 Mar 2025 15:19:06 GMT", "content-length": "16"} }
150+
// LWA: Intercepted resp body: b"{\"status\":\"OK\"}\n"
151+
// Extension is again ready, blocking on GET /invocation/next
152+
// LWA: Intercepted request: Parts { method: GET, uri: /2018-06-01/runtime/invocation/next, version: HTTP/1.1, headers: {"user-agent": "aws-lambda-rust/aws-lambda-adapter/0.9.0", "host": "127.0.0.1:9002"} }
153+
// LWA: Intercepted request body: b""
154+
136155
async fn intercept_payload(
137156
intercepted: Request<Body>,
138157
client: Arc<Client<ProxyConnector<HttpConnector>>>,

0 commit comments

Comments
 (0)