Move middlewares before the router

Hello @dpup, 

Just moved the middleware ordering


R=@dpup