Class: Highway::Application
- Inherits:
-
Object
- Object
- Highway::Application
- Defined in:
- lib/highway.rb,
lib/highway/routing.rb
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/highway.rb', line 7 def call(env) if env['PATH_INFO'] == '/favicon.ico' return [404, {'Content-Type' => 'text/html'}, []] end if env['PATH_INFO'] == '/' return [404, {'Content-Type' => 'text/html'}, 'home'] end klass, act = get_controller_and_action(env) controller = klass.new(env) text = controller.send(act) [200, {'Content-Type' => 'text/html'}, [text]] end |
#get_controller_and_action(env) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/highway/routing.rb', line 3 def get_controller_and_action(env) _, cont, action, after = env['PATH_INFO'].split('/', 4) cont = cont.capitalize # "People" cont += 'Controller' # 'PeopleController' [Object.const_get(cont), action] end |