Refactor the Rails 4 path for Application#default_middleware_stack.

This reflects the changes done in the Rails 4.1 refactor here:
https://github.com/rails/rails/commit/685309cf590cb49512bfd28b342d8aaa6c9f42eb

This is also backwards compatible with 4.0.x.
Merge pull request #114 from bmorton/refactor-default-middleware

Refactor the Rails 4 path for Application#default_middleware_stack.