Skip to content

Support multiple cookies with API Gateway v2#841

Merged
mnapoli merged 2 commits intomasterfrom
apigatewayv2-cookies
Jan 18, 2021
Merged

Support multiple cookies with API Gateway v2#841
mnapoli merged 2 commits intomasterfrom
apigatewayv2-cookies

Conversation

@mnapoli
Copy link
Member

@mnapoli mnapoli commented Jan 18, 2021

Fixes #818

Replaces #820

This PR allows apps to set multiple cookies in HTTP responses when using API Gateway v2.

Previously this wasn't possible because v2 does not support "multi-value headers". But they added a specific cookies field which we can use to set multiple cookies.

}
}

return array_change_key_case($responseHeaders, CASE_LOWER);
Copy link
Member Author

Choose a reason for hiding this comment

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

Headers are no returned unchanged because we normalize them later in any case. That simplifies the code.

$response = $this->handleRequest($httpEvent, $context);

if ($httpEvent->isFormatV2()) {
return $response->toApiGatewayFormatV2();
Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a completely separate method to avoid too many ifs and branches.

@mnapoli mnapoli merged commit 9150472 into master Jan 18, 2021
@mnapoli mnapoli deleted the apigatewayv2-cookies branch January 18, 2021 14:53
mnapoli added a commit that referenced this pull request Feb 14, 2023
Support multiple cookies with API Gateway v2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API Gateway v2: multiple response headers / multiple cookies

1 participant