Skip to content

Instantly share code, notes, and snippets.

@thejonanshow
Last active May 12, 2020 09:06
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 thejonanshow/2dc9e18a0e2c0a568dbab43f051692d2 to your computer and use it in GitHub Desktop.
Save thejonanshow/2dc9e18a0e2c0a568dbab43f051692d2 to your computer and use it in GitHub Desktop.
Justin wants to take Rails off the rails...
require "rack"
class Application
def call(env)
status = 200
headers = { "Content-Type" => "text/html" }
body = ["<h1>WHY?</h1>"]
[status, headers, body]
end
end
class First
def initialize(app)
@app = app
end
def call(env)
body1 = Second.new(@app).call(env).last
body2 = AlsoSecond.new(@app).call(env).last
status, headers, body = @app.call(env)
[status, headers, body2 + body1 + body]
end
end
class Second
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
[status, headers, ["<h2>Why Justin</h2>"]]
end
end
class AlsoSecond
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
[status, headers, ["<h3>WHY?</h3>"]]
end
end
use First
run Application.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment