make ok-json middleware. move non-route logic out of handler.