Files

HttpRouter::Rack::BuilderMixin

Replacement for {Rack::Builder} which using HttpRouter to map requests instead of a simple Hash. As well, add convenience methods for the request methods.

Public Instance Methods

delete(path, options = {}, &block) click to toggle source

Maps a path with request methods `DELETE` to a block. @param path [String] Path to map to. @param options [Hash] Options for added path. @see HttpRouter#add

# File lib/http_router/rack/builder.rb, line 50
def delete(path, options = {}, &block)
  map(path, options, :delete, &block)
end
get(path, options = {}, &block) click to toggle source

Maps a path with request methods `HEAD` and `GET` to a block. @param path [String] Path to map to. @param options [Hash] Options for added path. @see HttpRouter#add

# File lib/http_router/rack/builder.rb, line 26
def get(path, options = {}, &block)
  map(path, options, :get, &block)
end
map(path, options = {}, method = nil, &block) click to toggle source

Maps a path to a block. @param path [String] Path to map to. @param options [Hash] Options for added path. @see HttpRouter#add

# File lib/http_router/rack/builder.rb, line 14
def map(path, options = {}, method = nil, &block)
  route = router.add(path, options)
  route.send(method) if method
  route.to(&block)
  @ins << router unless @ins.last == router
  route
end
options(path, options = {}, &block) click to toggle source
# File lib/http_router/rack/builder.rb, line 54
def options(path, options = {}, &block)
  map(path, options, :options, &block)
end
post(path, options = {}, &block) click to toggle source

Maps a path with request methods `POST` to a block. @param path [String] Path to map to. @param options [Hash] Options for added path. @see HttpRouter#add

# File lib/http_router/rack/builder.rb, line 34
def post(path, options = {}, &block)
  map(path, options, :post, &block)
end
put(path, options = {}, &block) click to toggle source

Maps a path with request methods `PUT` to a block. @param path [String] Path to map to. @param options [Hash] Options for added path. @see HttpRouter#add

# File lib/http_router/rack/builder.rb, line 42
def put(path, options = {}, &block)
  map(path, options, :put, &block)
end
router() click to toggle source
# File lib/http_router/rack/builder.rb, line 6
def router
  @router ||= HttpRouter.new
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.