Introduce the concept of a middleware stack

In order to make PB more extensible, this introduces the concept of a
middleware stack. It is invoked from the server and terminates at the
dispatcher.

Add an env object used to pass stuff to/from the middleware:

- Use it in the dispatcher store the response and return it instead
- Use it in the server module to access stats, set the request, and
  process the response
Add a proper environment object w/ accessors