Load middleware after configuring app

This allows configuration options to be referenced when defining
middleware.

A subtle change is introduced here in that the builder is yielded to
the middleware block rather than the block being evaluated in context
of the builder.