Skip to content

Instantly share code, notes, and snippets.

@chhhris
Created June 21, 2013 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chhhris/5832365 to your computer and use it in GitHub Desktop.
Save chhhris/5832365 to your computer and use it in GitHub Desktop.
class MyApp
def call(env)
[200, {'Content-Type' => 'text/html'}, ['<a style="background-color:red;">URGENT MSG</a> from Tiny Tim: Hello']]
end
end
require './app.rb'
class ContentType
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
headers["Content-Type"] = "text/html"
[status, headers, body]
end
end
class FinishSentence
def initialize(app)
@app = app
end
def call(env)
status, headers, response = @app.call(env)
response_body = ""
response.each {|part| response_body += part}
response_body += " World!"
headers["Content-Length"] = response_body.length.to_s
[status, headers, [response_body]]
end
end
use FinishSentence
use ContentType
run MyApp.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment