Added hook for middleware