1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Merge pull request #897 from markbates/master

Added PROPFIND verb support
This commit is contained in:
Zachary Scott 2014-08-10 20:10:58 -07:00
commit 68c237d0c8
2 changed files with 16 additions and 11 deletions

View file

@ -53,7 +53,7 @@ module Sinatra
end
def safe?
get? or head? or options? or trace?
get? or head? or options? or trace? or propfind?
end
def idempotent?
@ -68,6 +68,10 @@ module Sinatra
request_method == "UNLINK"
end
def propfind?
request_method == "PROPFIND"
end
private
class AcceptEntry
@ -1373,14 +1377,15 @@ 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 options(path, opts = {}, &bk) route 'OPTIONS', path, opts, &bk end
def patch(path, opts = {}, &bk) route 'PATCH', path, opts, &bk end
def link(path, opts = {}, &bk) route 'LINK', path, opts, &bk end
def unlink(path, opts = {}, &bk) route 'UNLINK', 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
def patch(path, opts = {}, &bk) route 'PATCH', path, opts, &bk end
def link(path, opts = {}, &bk) route 'LINK', path, opts, &bk end
def unlink(path, opts = {}, &bk) route 'UNLINK', path, opts, &bk end
def propfind(path, opts = {}, &bk) route 'PROPFIND', path, opts, &bk end
# Makes the methods defined in the block and in the Modules given
# in `extensions` available to the handlers and templates
@ -1993,7 +1998,7 @@ module Sinatra
end
end
delegate :get, :patch, :put, :post, :delete, :head, :options, :link, :unlink,
delegate :get, :patch, :put, :post, :delete, :head, :options, :link, :unlink, :propfind,
:template, :layout, :before, :after, :error, :not_found, :configure,
:set, :mime_type, :enable, :disable, :use, :development?, :test?,
:production?, :helpers, :settings, :register

View file

@ -60,7 +60,7 @@ class DelegatorTest < Test::Unit::TestCase
assert_equal Sinatra::Application, Sinatra::Delegator.target
end
%w[get put post delete options patch link unlink].each do |verb|
%w[get put post delete options patch link unlink propfind].each do |verb|
it "delegates #{verb} correctly" do
delegation_app do
send(verb, '/hello') { 'Hello World' }