Implemented global middleware

Implemented global middleware. Uses the same mechanisms that route
specific middleware use. This required very minor refactoring and
i'm pretty happy with the results.

per issue #28