Sha256: f86db9fe3c406fcd3f3dc8555643b669793e03d877b0906b3d431b57e5b6b97b

Contents?: true

Size: 463 Bytes

Versions: 7

Compression:

Stored size: 463 Bytes

Contents

module Rasti
  module Web
    class Request < Rack::Request

      def initialize(env)
        super
        params.merge! JSON.parse(body_text) if json? && body_text
        params.merge! env[ROUTE_PARAMS] if env[ROUTE_PARAMS]
      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

7 entries across 7 versions & 1 rubygems

Version Path
rasti-web-0.0.7 lib/rasti/web/request.rb
rasti-web-0.0.6 lib/rasti/web/request.rb
rasti-web-0.0.5 lib/rasti/web/request.rb
rasti-web-0.0.4 lib/rasti/web/request.rb
rasti-web-0.0.3 lib/rasti/web/request.rb
rasti-web-0.0.2 lib/rasti/web/request.rb
rasti-web-0.0.1 lib/rasti/web/request.rb