Refactor API http handlers to prepare for versioning.