Module: Datadog::Lambda::AppSec::ResponseNormalizer
- Defined in:
- lib/datadog/lambda/appsec/response_normalizer.rb
Overview
Normalizes Lambda handler return values into a standard key set.
Class Method Summary collapse
-
.merge_headers(response) ⇒ Object
Merges single-value and multi-value headers into one hash with multi-value entries take priority when a key appears in both.
- .normalize(response) ⇒ Object
Class Method Details
.merge_headers(response) ⇒ Object
Merges single-value and multi-value headers into one hash with multi-value entries take priority when a key appears in both.
25 26 27 28 29 30 31 32 33 |
# File 'lib/datadog/lambda/appsec/response_normalizer.rb', line 25 def merge_headers(response) headers = response['headers'] multi_headers = response['multiValueHeaders'] return headers unless multi_headers return multi_headers unless headers headers.merge(multi_headers) end |
.normalize(response) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/datadog/lambda/appsec/response_normalizer.rb', line 12 def normalize(response) data = { 'status_code' => response['statusCode'], 'headers' => merge_headers(response), 'body' => response['body'], 'base64_encoded' => response['isBase64Encoded'] } data.compact! data end |