Allow extending Router.routes by accepting a function

A very simple change that implements discussion in #2255