aws/lambda/response
Typed responses for Lambda integrations that expect a structured reply, with encoders that produce the JSON Lambda marshals back to the caller.
Use these as the encode argument to aws/lambda.start_json.
Types
A proxy-integration response. The same shape serves API Gateway REST
(payload format 1.0) and HTTP API (payload format 2.0) proxy
integrations, as well as Lambda function URLs. cookies is encoded only
when non-empty (it is an HTTP API 2.0 field).
pub type ProxyResponse {
ProxyResponse(
status_code: Int,
headers: dict.Dict(String, String),
cookies: List(String),
body: String,
is_base64_encoded: Bool,
)
}
Constructors
-
ProxyResponse( status_code: Int, headers: dict.Dict(String, String), cookies: List(String), body: String, is_base64_encoded: Bool, )
Reports which messages in an SQS batch failed so Lambda redelivers only
those. Requires ReportBatchItemFailures on the event source mapping. An
empty list tells Lambda the whole batch succeeded.
pub type SqsBatchResponse {
SqsBatchResponse(batch_item_failures: List(String))
}
Constructors
-
SqsBatchResponse(batch_item_failures: List(String))
Values
pub fn proxy_response(
status_code: Int,
body: String,
) -> ProxyResponse
A 200 OK proxy response with a body and no extra headers. Set further
fields with record-update syntax:
response.proxy_response(201, "{}")
|> fn(r) { response.ProxyResponse(..r, headers: my_headers) }
pub fn proxy_to_json(response: ProxyResponse) -> json.Json
Encode a ProxyResponse to its Lambda JSON form.
pub fn sqs_batch_to_json(response: SqsBatchResponse) -> json.Json
Encode an SqsBatchResponse to its Lambda JSON form.