remove middleware, export a router function