rebuild router and middleware