Sha256: 3c2223eb3e088c713902ced2c917d7803c40079c0cbf324c53228c9a0cfcb87c

Contents?: true

Size: 938 Bytes

Versions: 4

Compression:

Stored size: 938 Bytes

Contents

module RackDAV

  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

4 entries across 4 versions & 2 rubygems

Version Path
rack_dav-0.4.1 lib/rack_dav/handler.rb
rack_dav-0.4.0 lib/rack_dav/handler.rb
rack_dav-0.3.1 lib/rack_dav/handler.rb
rack_dav_sp-0.2.dev lib/rack_dav/handler.rb