Skip to content

Instantly share code, notes, and snippets.

@gerred
Created May 25, 2011 17:31
Show Gist options
  • Save gerred/991433 to your computer and use it in GitHub Desktop.
Save gerred/991433 to your computer and use it in GitHub Desktop.
class App
def call(env)
[200, {"Content-Type" => "text/html"}, ["Hello!"]]
end
end
class Upper
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
body.map {|e| e.upcase!}
[status, headers, body]
end
end
class Headify
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
body.unshift "<h1>A header</h1>"
[status, headers, body]
end
end
use Upper
use Headify
run App.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment