public IHttpClient Create(string name, string baseUrl) { var key = BuildKey(name); if (_clients.ContainsKey(key)) { throw new AlreadyExistsException($"A client with name '{name}' already exists"); } var result = new NamedHttpClient(_logger, name, new HttpClient(), baseUrl); _clients.TryAdd(key, result); return result; }
public IHttpClient CreateOrUpdate(string name, string baseUrl) { var key = BuildKey(name); if (_clients.TryGetValue(key, out IHttpClient result)) { result.SetBaseUrl(baseUrl); return result; } result = new NamedHttpClient(_logger, name, new HttpClient(), baseUrl); _clients.TryAdd(key, result); return result; }