Class: Rambo::Request

Inherits:
Rack::Request
  • Object
show all
Defined in:
lib/rambo/request.rb

Instance Method Summary collapse

Instance Method Details

#acceptObject

Returns an array of acceptable media types for the response



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

def accept
  @env['HTTP_ACCEPT'].to_s.split(',').map { |a| a.strip }
end

#actionObject



36
37
38
# File 'lib/rambo/request.rb', line 36

def action
  path_components[2] || 'index'
end

#controllerObject



32
33
34
# File 'lib/rambo/request.rb', line 32

def controller
  path_components[1] || default_controller
end

#default_controllerObject



24
25
26
27
28
29
30
# File 'lib/rambo/request.rb', line 24

def default_controller
  if Rambo::Env.config['rambo']
    Rambo::Env.config['rambo']['default_controller'] || 'home'
  else
    'home'
  end
end

#paramsObject

Override Rack 0.9.x’s #params implementation (see #72 in lighthouse)



41
42
43
44
45
# File 'lib/rambo/request.rb', line 41

def params
  self.GET.update(self.POST)
rescue EOFError => boom
  self.GET
end

#pathObject



12
13
14
# File 'lib/rambo/request.rb', line 12

def path
  env["REQUEST_PATH"]
end

#path_componentsObject



20
21
22
# File 'lib/rambo/request.rb', line 20

def path_components
  @path_components ||= path.split('/')
end

#uriObject



16
17
18
# File 'lib/rambo/request.rb', line 16

def uri
  env["REQUEST_URI"]
end

#user_agentObject



3
4
5
# File 'lib/rambo/request.rb', line 3

def user_agent
  @env['HTTP_USER_AGENT']
end