clean up the logic around path inspection

- Replaced the brittle `trimSlash` stuff with `require('path').normalize`.
aggregate new middleware pieces via composition

As suggested in pull #1044.

We definitely need to refactor all the middleware and clean things up.
replace tunnel middleware with refactored version