I've created a lambda function and API gateway endpoint so that it echoes the query and header parameters it receives, and I want to parse the whole payload to JSON for manageability.
The received payloads is in this form:
"{Accept=*/*,
Accept-Encoding=gzip,
deflate,
Accept-Language=nb-NO,nb;q=0.8,no;q=0.6,nn;q=0.4,en-US;q=0.2,en;q=0.2,sv;q=0.2,da;q=0.2,
Authorization=COzTjCKD6VHTC,
Cache-Control=no-cache,
User-Agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36,
Via=1.1 7822a0bcea47c939c09def064206add3.cloudfront.net (CloudFront), X-Amz-Cf-Id=Bd_gFYsmhx0jK0eKf-3sZwwRozXtFoYC5UEFDDLKWYJkq6AR_L0Cfw==,
X-Forwarded-For=89.8.222.70, 205.251.218.72,
X-Forwarded-Port=443, X-Forwarded-Proto=https}"
It is not trivial to parse this manually (there is no escaping in the strings). What format is this, and are there some node libs to parse this format to JSON?
My requestTemplate:
"requestTemplates": {
"application/json": "{\"httpMethod\": \"$context.httpMethod\", \"route\": \"$input.params('route')\", \"query\": \"$input.params().querystring\", \"header\": \"$input.params().header\"}"
},