Class: Jets::Mega::Request::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/mega/request/source.rb

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ Source

Returns a new instance of Source.



3
4
5
6
7
# File 'lib/jets/mega/request/source.rb', line 3

def initialize(event)
  @event = event
  env = Jets::Controller::Rack::Env.new(@event, {}).convert # convert to Rack env
  @source_request = Rack::Request.new(env)
end

Instance Method Details

#bodyObject



9
10
11
12
13
14
15
# File 'lib/jets/mega/request/source.rb', line 9

def body
  if @source_request.body.respond_to?(:read)
    body = @source_request.body.read
    @source_request.body.rewind
  end
  body
end

#content_lengthObject



17
18
19
# File 'lib/jets/mega/request/source.rb', line 17

def content_length
  @source_request.content_length.to_i
end