Refactor HTTP replication endpoints to reduce code duplication