Sha256: e228cf8e7f35813574a332face9a7b93c91d28badc66b75222cd6511bbfc9034

Contents?: true

Size: 780 Bytes

Versions: 6

Compression:

Stored size: 780 Bytes

Contents

require "rack"

class GreetingApp

  include Rack::Utils
  
  def call(env)
    params = parse_nested_query(env["QUERY_STRING"])
    salutation = params[:salutation] || "Hello"
    subject = params[:subject] || "world"
    message = "#{salutation}, #{subject}"
    [
      "200 OK", 
      { "Content-Type" => "text/plain", "Content-Length" => message.length.to_s },
      [message]
    ]
  end
  
end

class EnvRecorder

  def initialize(app)
    @app = app
  end
  
  def call(env)
    @last_env = env
    @app.call(env)
  end

  attr_reader :last_env

end

class UpcaseBody

  def initialize(app)
    @app = app
  end

  def call(env)
    status, headers, body = @app.call(env)
    upcased_body = Array(body).map { |x| x.upcase }
    [status, headers, upcased_body]
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sham_rack-1.4.1 spec/test_apps.rb
sham_rack-1.4.0 spec/test_apps.rb
sham_rack-1.3.6 spec/test_apps.rb
sham_rack-1.3.5 spec/test_apps.rb
sham_rack-1.3.4 spec/test_apps.rb
sham_rack-1.3.3 spec/test_apps.rb