Refactor the Rails 4 path for Application#default_middleware_stack.

This is backwards compatible with 4.0.x and reflects the changes done in the Rails 4.1 refactor here:
https://github.com/rails/rails/commit/685309cf590cb49512bfd28b342d8aaa6c9f42eb

This also fixes the remaining failing test for ApiApplicationTest#test_boot_api_app.  Unfortunately, the app throwing a 500 makes that test fail, so both PR #111 and this PR are required to make that test pass.  This fixes issue #112.