Class: RackDAV::Handler
- Inherits:
-
Object
- Object
- RackDAV::Handler
- Defined in:
- lib/rack_dav/handler.rb
Constant Summary collapse
- ALLOWED_METHODS =
%w(GET PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE OPTIONS HEAD LOCK UNLOCK)
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
The hash of options.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(options = {}) ⇒ Handler
constructor
Initializes a new instance with given options.
Constructor Details
#initialize(options = {}) ⇒ Handler
Initializes a new instance with given options.
20 21 22 23 24 25 |
# File 'lib/rack_dav/handler.rb', line 20 def initialize( = {}) @options = { :resource_class => FileResource, :root => Dir.pwd }.merge() end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns The hash of options.
6 7 8 |
# File 'lib/rack_dav/handler.rb', line 6 def @options end |
Instance Method Details
#call(env) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rack_dav/handler.rb', line 27 def call(env) request = Rack::Request.new(env) response = Rack::Response.new begin controller = Controller.new(request, response, @options) if ALLOWED_METHODS.include?(request.request_method) controller.send(request.request_method.downcase) else response.status = 405 response['Allow'] = ALLOWED_METHODS.join(', ') end rescue HTTPStatus::Status => status response.status = status.code end response.finish end |