class Rack::Transform::Transformers::Base::Request
Constants
- CONTENT_LENGTH
- CONTENT_TYPE
- JSON_TYPE
- POST_BODY
Attributes
env[R]
Public Class Methods
call(env)
click to toggle source
# File lib/rack/transform/transformers/base.rb, line 11 def self.call(env) new(env).process end
new(env)
click to toggle source
# File lib/rack/transform/transformers/base.rb, line 17 def initialize(env) @env = env end
Public Instance Methods
process()
click to toggle source
# File lib/rack/transform/transformers/base.rb, line 21 def process raise NotImplementedError end
Private Instance Methods
dump_json(data)
click to toggle source
# File lib/rack/transform/transformers/base.rb, line 47 def dump_json(data) JSON.dump(data) end
params()
click to toggle source
# File lib/rack/transform/transformers/base.rb, line 31 def params req.params end
req()
click to toggle source
# File lib/rack/transform/transformers/base.rb, line 27 def req @req ||= Rack::Request.new(env) end
update_env(path:, query:, method:, body:)
click to toggle source
# File lib/rack/transform/transformers/base.rb, line 35 def update_env(path:, query:, method:, body:) body = body.is_a?(String) ? body : dump_json(body) env.update( Rack::PATH_INFO => path, Rack::QUERY_STRING => query, Rack::REQUEST_METHOD => method, CONTENT_TYPE => JSON_TYPE, CONTENT_LENGTH => body.bytesize, POST_BODY => StringIO.new(body) ) end