Created
June 21, 2013 16:18
-
-
Save chhhris/5832365 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApp | |
def call(env) | |
[200, {'Content-Type' => 'text/html'}, ['<a style="background-color:red;">URGENT MSG</a> from Tiny Tim: Hello']] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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