Move API version checking into middleware