How to use a custom router?

According to the code comments it “iterates through every route to find a matching route”.