title: Why does the order of Ring middleware need to be reversed?
body: <p>I'm writing some middleware for Ring and I'm really confused as to why I have to reverse the order of the middleware. </p>
  
  <p>I've found this <a href="http://squirrel.pl/blog/2012/04/10/ring-handlers-functional-decorator-pattern/">blog post</a> but it doesn't explain why I have to reverse it.</p>
  
  <p>Here's a quick excerpt from the blog post:</p>
  
  <pre><code>(def app
    (wrap-keyword-params (wrap-params my-handler)))
  </code></pre>
  
  <p>The response would be:</p>
  
  <pre><code>{; Trimmed for brevity
   :params {"my_param" "54"}}
  </code></pre>
  
  <p>Note that the wrap keyword params didn't get called on it because the params hash didn't exist yet. But when you reverse the order of the middleware like so:</p>
  
  <pre><code>(def app
    (wrap-params (wrap-keyword-params my-handler)))
  
  {; Trimmed for brevity
   :params {:my_param "54"}}
  </code></pre>
  
  <p>It works.</p>
  
  <p>Could somebody please explain why you have to reverse the order of the middleware?</p>