module Sapp::Routes

Use exclusively as a mixin for Base

Public Instance Methods

add(verb, path, &handler) click to toggle source
# File lib/sapp/routes.rb, line 29
def add verb, path, &handler
  route_map.add verb, path, &handler
end
Also aliased as: route
delete(path, &handler) click to toggle source
# File lib/sapp/routes.rb, line 49
def delete path, &handler
  add "DELETE", path, &handler
end
get(path, &handler) click to toggle source
# File lib/sapp/routes.rb, line 33
def get path, &handler
  add "GET", path, &handler
end
head(path, &handler) click to toggle source
# File lib/sapp/routes.rb, line 53
def head path, &handler
  add "HEAD", path, &handler
end
namespace(*names, nest: false) click to toggle source
# File lib/sapp/routes.rb, line 13
def namespace *names, nest: false
  route_map.set_namespace names, nest
end
not_found!(verb, path) click to toggle source
# File lib/sapp/routes.rb, line 25
def not_found! verb, path
  [404, {}, ["Oops! No route for #{verb} #{path}"]]
end
patch(path, &handler) click to toggle source
# File lib/sapp/routes.rb, line 45
def patch path, &handler
  add "PATCH", path, &handler
end
post(path, &handler) click to toggle source
# File lib/sapp/routes.rb, line 37
def post path, &handler
  add "POST", path, &handler
end
put(path, &handler) click to toggle source
# File lib/sapp/routes.rb, line 41
def put path, &handler
  add "PUT", path, &handler
end
root(&block) click to toggle source
# File lib/sapp/routes.rb, line 17
def root &block
  get '/', &block
end
route(verb, path, &handler)
Alias for: add
route_map() click to toggle source
# File lib/sapp/routes.rb, line 9
def route_map
  @route_map ||= RouteMap.new
end
routes() click to toggle source
# File lib/sapp/routes.rb, line 21
def routes
  route_map.routes
end