Fix repeated routing tree building.

Only build routing tree once as soon as routes are given to `route` and
return the actual function that performs request dispatching.