Sha256: f5d0408cbeb71cb973a6ac34aedf3cfc62ca18cdb928808d57ee4b80a3cb217e

Contents?: true

Size: 749 Bytes

Versions: 20

Compression:

Stored size: 749 Bytes

Contents

# encoding: utf-8

module Hyperdrive
  module Middleware
    class RequestMethod
      def initialize(app)
        @app = app
      end

      def call(env)
        http_request_method = env['REQUEST_METHOD']

        unless request_method_supported?(http_request_method)
          raise Hyperdrive::Errors::NotImplemented.new(http_request_method)
        end

        unless env['hyperdrive.resource'].request_method_allowed?(http_request_method)
          raise Hyperdrive::Errors::MethodNotAllowed.new(http_request_method)
        end

        @app.call(env)
      end

      private
  
      def request_method_supported?(http_request_method)
        Hyperdrive::Values.http_request_methods.key?(http_request_method)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
hyperdrive-0.0.25 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.24 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.23 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.22 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.21 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.20 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.19 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.18 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.17 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.16 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.15 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.14 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.13 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.12 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.11 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.10 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.9 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.8 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.7 lib/hyperdrive/middleware/request_method.rb
hyperdrive-0.0.6 lib/hyperdrive/middleware/request_method.rb