Module: Sapp::Routes
- Included in:
- Base
- Defined in:
- lib/sapp/routes.rb
Overview
Use exclusively as a mixin for Base
Instance Method Summary collapse
- #add(verb, path, &handler) ⇒ Object (also: #route)
- #delete(path, &handler) ⇒ Object
- #get(path, &handler) ⇒ Object
- #head(path, &handler) ⇒ Object
- #namespace(*names, nest: false) ⇒ Object
- #not_found!(verb, path) ⇒ Object
- #patch(path, &handler) ⇒ Object
- #post(path, &handler) ⇒ Object
- #put(path, &handler) ⇒ Object
- #root(&block) ⇒ Object
- #route_map ⇒ Object
- #routes ⇒ Object
Instance Method Details
#add(verb, path, &handler) ⇒ Object Also known as: route
29 30 31 |
# File 'lib/sapp/routes.rb', line 29 def add verb, path, &handler route_map.add verb, path, &handler end |
#delete(path, &handler) ⇒ Object
49 50 51 |
# File 'lib/sapp/routes.rb', line 49 def delete path, &handler add "DELETE", path, &handler end |
#get(path, &handler) ⇒ Object
33 34 35 |
# File 'lib/sapp/routes.rb', line 33 def get path, &handler add "GET", path, &handler end |
#head(path, &handler) ⇒ Object
53 54 55 |
# File 'lib/sapp/routes.rb', line 53 def head path, &handler add "HEAD", path, &handler end |
#namespace(*names, nest: false) ⇒ Object
13 14 15 |
# File 'lib/sapp/routes.rb', line 13 def namespace *names, nest: false route_map.set_namespace names, nest end |
#not_found!(verb, path) ⇒ Object
25 26 27 |
# File 'lib/sapp/routes.rb', line 25 def not_found! verb, path [404, {}, ["Oops! No route for #{verb} #{path}"]] end |
#patch(path, &handler) ⇒ Object
45 46 47 |
# File 'lib/sapp/routes.rb', line 45 def patch path, &handler add "PATCH", path, &handler end |
#post(path, &handler) ⇒ Object
37 38 39 |
# File 'lib/sapp/routes.rb', line 37 def post path, &handler add "POST", path, &handler end |
#put(path, &handler) ⇒ Object
41 42 43 |
# File 'lib/sapp/routes.rb', line 41 def put path, &handler add "PUT", path, &handler end |
#root(&block) ⇒ Object
17 18 19 |
# File 'lib/sapp/routes.rb', line 17 def root &block get '/', &block end |
#route_map ⇒ Object
9 10 11 |
# File 'lib/sapp/routes.rb', line 9 def route_map @route_map ||= RouteMap.new end |
#routes ⇒ Object
21 22 23 |
# File 'lib/sapp/routes.rb', line 21 def routes route_map.routes end |