Sha256: af2b6934b2d88f22855ca19b2aa5949c42f8806800b9415841435462c1711d88

Contents?: true

Size: 941 Bytes

Versions: 2

Compression:

Stored size: 941 Bytes

Contents

module RackWebDAV

  class Handler

    # @return [Hash] The hash of options.
    attr_reader :options


    # Initializes a new instance with given options.
    #
    # @param  [Hash] options Hash of options to customize the handler behavior.
    # @option options [Class] :resource_class (FileResource)
    #         The resource class.
    # @option options [String] :root (".")
    #         The root resource folder.
    #
    def initialize(options = {})
      @options = {
        :resource_class => FileResource,
        :root => Dir.pwd
      }.merge(options)
    end

    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

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-webdav-0.4.5 lib/rack-webdav/handler.rb
rack-webdav-0.4.4 lib/rack-webdav/handler.rb