Routing refactor, authentication middleware template