Refactor HTTP API into repository structure