Fix ordering of registering the StaticDispatcher middleware

There was a chance that the registration of the StaticDispatcher was called
after the middleware stack was already initialized. Also not using the
Apipie.configuration at that point, as the rails initializer setting the
configuration might not be run yet by that time.