Pass the extension to any middleware classes being constructed.

The new middleware support wasn't as useful without having a reference
to the extension. This is now passed to the constructor.

It's worth noting that this will break any extensions that are taking
advantage of custom middleware, but as that was introduced in the
beta, oh wells.