Skip to content
Open
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
11 changes: 6 additions & 5 deletions events/lambda_function_urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ type LambdaFunctionURLRequestContextHTTPDescription struct {

// LambdaFunctionURLResponse configures the HTTP response to be returned by Lambda Function URL for the request.
type LambdaFunctionURLResponse struct {
StatusCode int `json:"statusCode"`
Headers map[string]string `json:"headers"`
Body string `json:"body"`
IsBase64Encoded bool `json:"isBase64Encoded"`
Cookies []string `json:"cookies"`
StatusCode int `json:"statusCode"`
Headers map[string]string `json:"headers"`
MultiValueHeaders map[string][]string `json:"multiValueHeaders,omitempty"`
Body string `json:"body"`
IsBase64Encoded bool `json:"isBase64Encoded"`
Cookies []string `json:"cookies"`
}

// LambdaFunctionURLStreamingResponse models the response to a Lambda Function URL when InvokeMode is RESPONSE_STREAM.
Expand Down
21 changes: 21 additions & 0 deletions events/lambda_function_urls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,27 @@ func TestLambdaFunctionURLRequestMarshaling(t *testing.T) {
assert.JSONEq(t, string(inputJSON), string(outputJSON))
}

func TestLambdaFunctionURLResponseMultiValueHeadersMarshaling(t *testing.T) {
inputJSON, err := ioutil.ReadFile("./testdata/lambda-urls-response-multi-value-headers.json")
if err != nil {
t.Errorf("could not open test file. details: %v", err)
}

var inputEvent LambdaFunctionURLResponse
if err := json.Unmarshal(inputJSON, &inputEvent); err != nil {
t.Errorf("could not unmarshal event. details: %v", err)
}

require.Equal(t, []string{"a=1; Path=/", "b=2; Path=/"}, inputEvent.MultiValueHeaders["Set-Cookie"])

outputJSON, err := json.Marshal(inputEvent)
if err != nil {
t.Errorf("could not marshal event. details: %v", err)
}

assert.JSONEq(t, string(inputJSON), string(outputJSON))
}

func TestLambdaFunctionURLStreamingResponseMarshaling(t *testing.T) {
for _, test := range []struct {
name string
Expand Down
12 changes: 12 additions & 0 deletions events/testdata/lambda-urls-response-multi-value-headers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"statusCode": 200,
"headers": {
"Content-Type": "application/json"
},
"multiValueHeaders": {
"Set-Cookie": ["a=1; Path=/", "b=2; Path=/"]
},
"body": "",
"cookies": [],
"isBase64Encoded": false
}
Loading