Class: Rasti::Web::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/rasti/web/router.rb

Constant Summary collapse

VERBS =
%w(delete get head options patch post put).freeze
NOT_FOUND_PATTERN =
'/404'

Instance Method Summary collapse

Instance Method Details

#all_routesObject



25
26
27
# File 'lib/rasti/web/router.rb', line 25

def all_routes
  Hash[routes.map { |m,r| [m, r.map(&:pattern)] }]
end

#call(env) ⇒ Object



19
20
21
22
23
# File 'lib/rasti/web/router.rb', line 19

def call(env)
  route = route_for env 
  env[ROUTE_PARAMS] = route.extract_params env['PATH_INFO']
  route.call env
end

#not_found(endpoint = nil, &block) ⇒ Object



15
16
17
# File 'lib/rasti/web/router.rb', line 15

def not_found(endpoint=nil, &block)
  @not_found_route = Route.new(NOT_FOUND_PATTERN, endpoint, &block)
end