Class: RackDAV::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/rack_dav/handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Handler

Initializes a new instance with given options.

Parameters:

  • options (Hash) (defaults to: {})

    Hash of options to customize the handler behavior.

Options Hash (options):

  • :resource_class (Class) — default: FileResource

    The resource class.

  • :root (String) — default: "."

    The root resource folder.



17
18
19
20
21
22
# File 'lib/rack_dav/handler.rb', line 17

def initialize(options = {})
  @options = {
    :resource_class => FileResource,
    :root => Dir.pwd
  }.merge(options)
end

Instance Attribute Details

#optionsHash (readonly)

Returns The hash of options.

Returns:

  • (Hash)

    The hash of options.



6
7
8
# File 'lib/rack_dav/handler.rb', line 6

def options
  @options
end

Instance Method Details

#call(env) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rack_dav/handler.rb', line 24

def call(env)
  request  = Rack::Request.new(env)
  response = Rack::Response.new

  begin
    controller = Controller.new(request, response, @options)
    controller.send(request.request_method.downcase)

  rescue HTTPStatus::Status => status
    response.status = status.code
  end

  response.finish
end