Just a couple of questions on this one:

1. The comment says development only... what makes it work only in development?
2. I don't understand why this is only getting triggered when an error occurs. I assumed that anything you stick in the middleware would get triggered on every request, but I tried it out and it's (correctly) only getting triggered when there's an error. Is there something about the callback definition or something that makes it work this way? It's working how it should (as far as I can tell), I'm just trying to understand why.  : )