Class: Gnarly::Request

Inherits:
Object
  • Object
show all
Includes:
QueryStringParser
Defined in:
lib/gnarly/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state) ⇒ Request

Returns a new instance of Request.



10
11
12
13
# File 'lib/gnarly/request.rb', line 10

def initialize(state)
  @state = state
  parse_content_type
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



8
9
10
# File 'lib/gnarly/request.rb', line 8

def state
  @state
end

Instance Method Details

#acceptObject



23
24
25
# File 'lib/gnarly/request.rb', line 23

def accept()
  @accept ||= @state["HTTP_ACCEPT"]
end

#bodyObject



35
36
37
38
39
40
41
42
43
# File 'lib/gnarly/request.rb', line 35

def body()
  unless @body
    input = @state["rack.input"]
    @body = input.read
    input.rewind
    @body.force_encoding charset if charset
  end
  @body
end

#charsetObject



31
32
33
# File 'lib/gnarly/request.rb', line 31

def charset()
  @charset
end

#content_typeObject



27
28
29
# File 'lib/gnarly/request.rb', line 27

def content_type()
  @content_type
end

#methodObject



19
20
21
# File 'lib/gnarly/request.rb', line 19

def method()
  @method ||= @state["REQUEST_METHOD"].downcase.to_sym
end

#paramsObject



45
46
47
# File 'lib/gnarly/request.rb', line 45

def params()
  @params ||= qs_parse(@state["QUERY_STRING"])
end

#pathObject



15
16
17
# File 'lib/gnarly/request.rb', line 15

def path()
  @path ||= @state["PATH_INFO"]
end