module Truss::Router
Constants
- VERSION
Public Instance Methods
call(env)
click to toggle source
# File lib/truss/router.rb, line 52 def call env request = Request.new(env.dup) route = routeset.find_route(request) if route route.call(request) else [404, {'Content-Type' => 'text/plain'}, ["Not Found"]] end end
delete(path, endpoint, opts={})
click to toggle source
# File lib/truss/router.rb, line 44 def delete(path, endpoint, opts={}) build_node :Delete, path, endpoint, opts end
draw(&block)
click to toggle source
# File lib/truss/router.rb, line 11 def draw(&block) raise ArgumentError unless block_given? block.call(self) end
get(path, endpoint, opts={})
click to toggle source
# File lib/truss/router.rb, line 20 def get(path, endpoint, opts={}) build_node :Get, path, endpoint, opts end
head(path, endpoint, opts={})
click to toggle source
# File lib/truss/router.rb, line 32 def head(path, endpoint, opts={}) build_node :Head, path, endpoint, opts end
options(path, endpoint, opts={})
click to toggle source
# File lib/truss/router.rb, line 28 def options(path, endpoint, opts={}) build_node :Options, path, endpoint, opts end
patch(path, endpoint, opts={})
click to toggle source
# File lib/truss/router.rb, line 40 def patch(path, endpoint, opts={}) build_node :Patch, path, endpoint, opts end
post(path, endpoint, opts={})
click to toggle source
# File lib/truss/router.rb, line 24 def post(path, endpoint, opts={}) build_node :Post, path, endpoint, opts end
put(path, endpoint, opts={})
click to toggle source
# File lib/truss/router.rb, line 36 def put(path, endpoint, opts={}) build_node :Put, path, endpoint, opts end
reset!()
click to toggle source
# File lib/truss/router.rb, line 48 def reset! @routeset = Truss::Router::Routeset.new end
routeset()
click to toggle source
# File lib/truss/router.rb, line 16 def routeset @routeset ||= Truss::Router::Routeset.new end
Protected Instance Methods
build_node(method, path, endpoint, opts)
click to toggle source
# File lib/truss/router.rb, line 63 def build_node method, path, endpoint, opts routeset.add_node Routes.const_get(method).new(path, endpoint, opts) end