Sha256: 14fddaeab0a1c8126a710eb3ecc1e8583c0fc8d527c749702d7470e098c90678

Contents?: true

Size: 525 Bytes

Versions: 38

Compression:

Stored size: 525 Bytes

Contents

module Rack::App::InstanceMethods::Payload

  def payload
    request.env[Rack::App::Constants::ENV::PAYLOAD_GETTER].call
  end

  def payload_stream
    return nil unless @request.body.respond_to?(:gets)
    while chunk = @request.body.gets
      yield(chunk)
    end
    @request.body.rewind
    nil
  end

  def payload_to_file(file_path, file_mod='w')
    return nil unless @request.body.respond_to?(:gets)
    File.open(file_path, file_mod) do |file|
      payload_stream{ |chunk| file.print(chunk) }
    end
  end

end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/rack-app-7.7.0/lib/rack/app/instance_methods/payload.rb
rack-app-7.7.0 lib/rack/app/instance_methods/payload.rb
rack-app-7.6.5 lib/rack/app/instance_methods/payload.rb
rack-app-7.6.4 lib/rack/app/instance_methods/payload.rb
rack-app-7.6.3 lib/rack/app/instance_methods/payload.rb
rack-app-7.6.2 lib/rack/app/instance_methods/payload.rb
rack-app-7.6.1 lib/rack/app/instance_methods/payload.rb
rack-app-7.6.0 lib/rack/app/instance_methods/payload.rb
rack-app-7.5.2 lib/rack/app/instance_methods/payload.rb
rack-app-7.5.1 lib/rack/app/instance_methods/payload.rb
rack-app-7.5.0 lib/rack/app/instance_methods/payload.rb
rack-app-7.4.0 lib/rack/app/instance_methods/payload.rb
rack-app-7.3.2 lib/rack/app/instance_methods/payload.rb
rack-app-7.3.1 lib/rack/app/instance_methods/payload.rb
rack-app-7.3.0 lib/rack/app/instance_methods/payload.rb
rack-app-7.2.2 lib/rack/app/instance_methods/payload.rb
rack-app-7.2.1 lib/rack/app/instance_methods/payload.rb
rack-app-7.2.0 lib/rack/app/instance_methods/payload.rb
rack-app-7.1.0 lib/rack/app/instance_methods/payload.rb
rack-app-7.0.0 lib/rack/app/instance_methods/payload.rb