Update middleware interface

So that Sentry gets installed in a place where is can log the most exceptions.

See https://github.com/ckan/ckan/pull/1836