11# MIT No Attribution
2-
2+
33# Permission is hereby granted, free of charge, to any person obtaining a copy of this
44# software and associated documentation files (the "Software"), to deal in the Software
55# without restriction, including without limitation the rights to use, copy, modify,
66# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
77# permit persons to whom the Software is furnished to do so.
8-
8+
99# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
1010# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
1111# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
@@ -28,16 +28,18 @@ def handler(event:, context:)
2828 else
2929 body = event [ 'body' ]
3030 end
31+ # Rack expects the querystring in plain text, not a hash
32+ querystring = Rack ::Utils . build_query ( event [ 'queryStringParameters' ] ) if event [ 'queryStringParameters' ]
3133 # Environment required by Rack (http://www.rubydoc.info/github/rack/rack/file/SPEC)
3234 env = {
3335 "REQUEST_METHOD" => event [ 'httpMethod' ] ,
3436 "SCRIPT_NAME" => "" ,
3537 "PATH_INFO" => event [ 'path' ] || "" ,
36- "QUERY_STRING" => event [ 'queryStringParameters' ] || "" ,
38+ "QUERY_STRING" => querystring || "" ,
3739 "SERVER_NAME" => "localhost" ,
3840 "SERVER_PORT" => 443 ,
3941 "CONTENT_TYPE" => event [ 'headers' ] [ 'content-type' ] ,
40-
42+
4143 "rack.version" => Rack ::VERSION ,
4244 "rack.url_scheme" => "https" ,
4345 "rack.input" => StringIO . new ( body || "" ) ,
@@ -57,7 +59,7 @@ def handler(event:, context:)
5759 body . each do |item |
5860 body_content += item . to_s
5961 end
60-
62+
6163 # We return the structure required by AWS API Gateway since we integrate with it
6264 # https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
6365 response = {
0 commit comments