Sha256: 8131a60cad8f5f34e650927556a7ff32a3e72d1a0b539d6a7740e626a86cefbd

Contents?: true

Size: 673 Bytes

Versions: 1

Compression:

Stored size: 673 Bytes

Contents

require 'sparrow/middleware'

module Sparrow
  class RequestMiddleware < Middleware
    def convert(env)
      super
      strategy.handle(env, :request)
      env
    end

    def content_type
      my_content_type = request.content_type ||
          last_env['CONTENT-TYPE'] ||
          last_env['Content-Type'] ||
          last_env['CONTENT_TYPE']

      my_content_type.present? ? my_content_type : nil
    end

    def strategy
      if is_processable? && last_env[Strategies::FormHash::REQUEST_FORM_HASH_KEY]
        Rails.logger.debug 'Choosing strategy FormHash' if defined? Rails
        Strategies::FormHash
      else
        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cp-sparrow-0.0.12 lib/sparrow/request_middleware.rb