Class: Jets::Controller::RackAdapter::Env
- Inherits:
-
Object
- Object
- Jets::Controller::RackAdapter::Env
- Defined in:
- lib/jets/controller/rack_adapter/env.rb
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(event, context, options = {}) ⇒ Env
constructor
A new instance of Env.
Constructor Details
#initialize(event, context, options = {}) ⇒ Env
Returns a new instance of Env.
8 9 10 |
# File 'lib/jets/controller/rack_adapter/env.rb', line 8 def initialize(event, context, ={}) @event, @context, @options = event, context, end |
Instance Method Details
#convert ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jets/controller/rack_adapter/env.rb', line 12 def convert = {} = add_top_level() = add_http_headers() path = path_with_base_path || @event['path'] || '/' # always set by API Gateway but might not be when testing shim, so setting it to make testing easier # In case of non-ascii characters, CGI.escape will escape them # IE: get '/ほげ' # This just because MockRequest.env_for uses URI.parse which does not # escape non-ascii characters and throws an error unescaped_path = path path = path.chars.map { |char| char.ascii_only? ? char : CGI.escape(char) }.join env = Rack::MockRequest.env_for(path, ) env['PATH_INFO'] = unescaped_path # env['QUERY_STRING'] = query_string env end |