Last active
May 12, 2020 09:06
-
-
Save thejonanshow/2dc9e18a0e2c0a568dbab43f051692d2 to your computer and use it in GitHub Desktop.
Revisions
-
thejonanshow revised this gist
May 12, 2020 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -19,9 +19,8 @@ class First 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 -
thejonanshow renamed this gist
May 12, 2020 . 1 changed file with 8 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ class Application def call(env) status = 200 headers = { "Content-Type" => "text/html" } body = ["<h1>WHY?</h1>"] [status, headers, body] end @@ -16,11 +16,12 @@ def initialize(app) end def call(env) body1 = Second.new(@app).call(env).last body2 = AlsoSecond.new(@app).call(env).last @app.call(env).tap do |result| result[-1] = [body2, body1, result.last].flatten end end end @@ -31,7 +32,7 @@ def initialize(app) def call(env) status, headers, body = @app.call(env) [status, headers, ["<h2>Why Justin</h2>"]] end end @@ -42,7 +43,7 @@ def initialize(app) def call(env) status, headers, body = @app.call(env) [status, headers, ["<h3>WHY?</h3>"]] end end -
thejonanshow created this gist
May 12, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ require "rack" class Application def call(env) status = 200 headers = { "Content-Type" => "text/html" } body = ["WE DID IT! WHY?"] [status, headers, body] end end class First def initialize(app) @app = app end def call(env) status, headers, body1 = Second.new(@app).call(env) status, headers, body2 = AlsoSecond.new(@app).call(env) status, headers, body0 = @app.call(env) [status, headers, body0 + body1 + body2] end end class Second def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) [status, headers, ["\tSecond"]] end end class AlsoSecond def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) [status, headers, ["\tAlsoSecond"]] end end use First run Application.new