Updates the routes API to allow route closures to be registered with the
system, and adds logic to call the closures for frontend routes.