Added support for OPTIONS request type.

Signed-off-by: Konstantin Haase <konstantin.mailinglists@googlemail.com>
This commit is contained in:
jammur 2010-11-29 15:03:08 -05:00 committed by Konstantin Haase
parent 2943e9383b
commit 4d0b7403ac
2 changed files with 8 additions and 7 deletions

View File

@ -1027,11 +1027,12 @@ module Sinatra
route('HEAD', path, opts, &block)
end
def put(path, opts={}, &bk); route 'PUT', path, opts, &bk end
def post(path, opts={}, &bk); route 'POST', path, opts, &bk end
def delete(path, opts={}, &bk); route 'DELETE', path, opts, &bk end
def head(path, opts={}, &bk); route 'HEAD', path, opts, &bk end
def put(path, opts={}, &bk); route 'PUT', path, opts, &bk end
def post(path, opts={}, &bk); route 'POST', path, opts, &bk end
def delete(path, opts={}, &bk); route 'DELETE', path, opts, &bk end
def head(path, opts={}, &bk); route 'HEAD', path, opts, &bk end
def options(path, opts={}, &bk); route 'OPTIONS', path, opts, &bk end
private
def route(verb, path, options={}, &block)
# Because of self.options.host
@ -1363,7 +1364,7 @@ module Sinatra
end
end
delegate :get, :put, :post, :delete, :head, :template, :layout,
delegate :get, :put, :post, :delete, :head, :options, :template, :layout,
:before, :after, :error, :not_found, :configure, :set, :mime_type,
:enable, :disable, :use, :development?, :test?, :production?,
:helpers, :settings

View File

@ -23,7 +23,7 @@ class RegexpLookAlike
end
class RoutingTest < Test::Unit::TestCase
%w[get put post delete].each do |verb|
%w[get put post delete options].each do |verb|
it "defines #{verb.upcase} request handlers with #{verb}" do
mock_app {
send verb, '/hello' do