Middleware refactoring

James,
Here is the refactoring for the middleware that we have been discussing with you. We'd love to see this pulled in and applied. But, please let me know if you have any questions or concerns with any of the changes.

A couple of things of note.
* We've made params/assoc-form-params public because we've found it to be useful outside of the handler itself.
* Now that we've split the request and response handling into separate functions - do you have a preferred way for us to indicate that is intentional? For instance, should we add basic tests that verify that the request and response functions both exist and are public? The concern here is that a future maintainer might look at this split and think it's unnecessarily complex and decide to revert it. Just looking for what you think is the best way to indicate this for future posterity.

Thanks, and let me know if I can help with anything.