I'm not sure these functions make sense in the middleware namespace, as none of them are actual middleware. Or move the stuff from within middleware.clj to here?