package com.develop.food.base.http

object BaseRequest {
    private val serviceMap = mutableMapOf<String, Any>()

    @Synchronized
    fun <T> get(tClass: Class<*>, factory: HttpFactory): T {
        val baseUrl = factory.baseUrl
        val service = serviceMap[baseUrl]
        if (service != null) {
            return service as T
        }
        val created = BaseRetrofit(tClass, factory).getSerVice()
        serviceMap[baseUrl] = created as Any
        return created as T
    }

    fun clearMap() {
        serviceMap.clear()
    }
}