move cli-server routing code into separate router php file from index.php

This change aims to remove checking if cli-server. (optimization for non-debugging product environment)