Support specifying standard and extension-specific middleware.

Extensions recently gained support for loading additional middleware,
and I recently updated it to require that the middleware take an
extension parameter in the constructor. However, this makes it harder to
use middleware provided by third-parties that aren't extension-aware.

Now, we introspect the middleware's constructor and see if it's
extension-aware or not. We can then initialize it appropriately.