winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.77k stars 189 forks source link

Support multi-value headers in cloud.Api #4439

Open skyrpex opened 9 months ago

skyrpex commented 9 months ago

Feature Spec

The cloud.Api resource now supports multi-value headers in cloud.ApiResponse, as seen in the following example:

bring cloud;

let api = new cloud.Api();

api.get("/create-cookies", inflight () => {
  return cloud.ApiResponse {
    headers: {
      "Set-Cookie": "one-cookie=hey",
    },
    multiValueHeaders: {
      "Set-Cookie": ["auth=true", "another-cookie=hello"],
    },
  };
});

Alternative syntax (also backwards incompatible):

bring cloud;

let api = new cloud.Api();

api.get("/create-cookies", inflight () => {
  return cloud.ApiResponse {
    headers: {
      "Set-Cookie": ["one-cookie=hey", "auth=true", "another-cookie=hello"],
    },
  };
});

Use Cases

Enables using multiple cookies in APIs.

Implementation Notes

AWS Lambda also uses multiValueHeaders in addition of headers. See https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-output-format.

Component

SDK

Community Notes

github-actions[bot] commented 6 months ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!