Sha256: 9d8a2c91ae7274f528945669618f8a49b5b259b8e4c7216d720e596830059e60
Contents?: true
Size: 795 Bytes
Versions: 4
Compression:
Stored size: 795 Bytes
Contents
require 'rack-webdav/interceptor_resource' module RackWebDAV class Interceptor def initialize(app, args={}) @roots = args[:mappings].keys @args = args @app = app @intercept_methods = %w(OPTIONS PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK) @intercept_methods -= args[:ignore_methods] if args[:ignore_methods] end def call(env) path = env['PATH_INFO'].downcase method = env['REQUEST_METHOD'].upcase app = nil if(@roots.detect{|x| path =~ /^#{Regexp.escape(x.downcase)}\/?/}.nil? && @intercept_methods.include?(method)) app = RackWebDAV::Handler.new(:resource_class => InterceptorResource, :mappings => @args[:mappings], :log_to => @args[:log_to]) end app ? app.call(env) : @app.call(env) end end end
Version data entries
4 entries across 4 versions & 1 rubygems