Allow routes to be completely customized

This is a backport of some changes from the 2.0 branch.
Elsewhere in this file we seem to use `expect(...).to ...` syntax.