Sha256: f1315b4ba54c5e6f9453d975b98e506de5ff99867a16644c5c6b58f85d161929

Contents?: true

Size: 575 Bytes

Versions: 1

Compression:

Stored size: 575 Bytes

Contents

module Rasti
  module Web
    class Request < Rack::Request

      def params
        @params ||= Hash::Indifferent.new.tap do |hash|
          hash.update self.GET
          hash.update self.POST
          hash.update env[ROUTE_PARAMS] if env.key? ROUTE_PARAMS
          hash.update JSON.parse(body_text) if json? && body_text
        end
      end

      def body_text
        @body_text ||= begin 
          text = body.read
          body.rewind
          text
        end
      end

      def json?
        content_type == 'application/json'
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rasti-web-0.1.0 lib/rasti/web/request.rb