Skip to content
This repository
Browse code

Tap, tap goes the middleware

  • Loading branch information...
commit ceb66b61264657898cd6608c7e9ed78072169664 1 parent f9995ce
Jeremy Kemper authored February 29, 2012
5  actionpack/lib/action_dispatch/middleware/request_id.rb
@@ -19,10 +19,7 @@ def initialize(app)
19 19
 
20 20
     def call(env)
21 21
       env["action_dispatch.request_id"] = external_request_id(env) || internal_request_id
22  
-      status, headers, body = @app.call(env)
23  
-
24  
-      headers["X-Request-Id"] = env["action_dispatch.request_id"]
25  
-      [ status, headers, body ]
  22
+      @app.call(env).tap { |status, headers, body| headers["X-Request-Id"] = env["action_dispatch.request_id"] }
26 23
     end
27 24
 
28 25
     private

9 notes on commit ceb66b6

Aaron Patterson
Owner

Pretty sure that's more than 80 columns. :trollface:

José Valim
Owner

Yes, we should probably use s, h and b as variables to ensure it won't be more than 80 columns. :trollface:

Xavier Noria
Owner

Problem are 2D editors, if that line could be rolled in a 3rd dimension it would fit even in the screen of a Sinclair Spectrum.

Gabriel Sobrinho

You could break into do/end block:

@app.call(env).tap do |status, headers, body|
  headers["X-Request-Id"] = env["action_dispatch.request_id"]
end

:)

Jeremy Kemper
Owner

Too many blocks and hash lookups. This is why Rails is slow. :trollface:

Egor Homakov

jeremy, are you talkinng to sobrinho? His code looks much clearer.
y all are trying to code using 1 line. it makes things more obscure :(

José Valim
Owner
Xavier Noria
Owner
fxn commented on ceb66b6 March 01, 2012

To be honest I don't have a Sinclair Spectrum either, more of an Amstrad guy over here :beer:

Egor Homakov

#5239 my time to troll jaja

Please sign in to comment.
Something went wrong with that request. Please try again.