Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lambda-http/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn into_api_gateway_v2_request(ag: ApiGatewayV2httpRequest) -> http::Request<Bod
.headers
.get(http::header::HOST)
.and_then(|s| s.to_str().ok())
.or_else(|| ag.request_context.domain_name.as_deref())
.or(ag.request_context.domain_name.as_deref())
.unwrap_or_default();

let path = apigw_path_with_stage(&ag.request_context.stage, ag.raw_path.as_deref().unwrap_or_default());
Expand Down
23 changes: 19 additions & 4 deletions lambda-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,30 @@ where
{
let client = &self.client;
tokio::pin!(incoming);
while let Some(event) = incoming.next().await {
while let Some(next_event_response) = incoming.next().await {
trace!("New event arrived (run loop)");
let event = event?;
let event = next_event_response?;
let (parts, body) = event.into_parts();

#[cfg(debug_assertions)]
if parts.status == http::StatusCode::NO_CONTENT {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can an AWS server return this status? If not, should this be under an optional flag or for debug only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why should we complicate it more than this?

// Ignore the event if the status code is 204.
// This is a way to keep the runtime alive when
// there are no events pending to be processed.
continue;
}

let body = hyper::body::to_bytes(body).await?;
trace!("response body - {}", std::str::from_utf8(&body)?);

#[cfg(debug_assertions)]
if parts.status.is_server_error() {
error!("Lambda Runtime server returned an unexpected error");
return Err(parts.status.to_string().into());
}

let ctx: Context = Context::try_from(parts.headers)?;
let ctx: Context = ctx.with_config(config);
let body = hyper::body::to_bytes(body).await?;
trace!("{}", std::str::from_utf8(&body)?); // this may be very verbose
let body = serde_json::from_slice(&body)?;

let xray_trace_id = &ctx.xray_trace_id.clone();
Expand Down