Refactor route handling to be configuration based.