/// <summary> /// Создать api клиент c jwt токеном /// </summary> public static IRestHttpClient GetRestClient(IHostConfigurationDomain hostConfiguration, string jwtToken) => new HttpClientHandler(). VoidOk(handler => hostConfiguration.DisableSSL, handler => handler.ClientCertificateOptions = ClientCertificateOption.Manual). VoidOk(handler => hostConfiguration.DisableSSL, handler => handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => true). Map(handler => new HttpClient(handler) { BaseAddress = hostConfiguration.Host, Timeout = hostConfiguration.TimeOut, }). VoidOk(_ => !String.IsNullOrWhiteSpace(jwtToken), httpClient => httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(JWT_SCHEME, jwtToken)). Map(httpClient => new RestHttpClient(httpClient));
/// <summary> /// Создать api клиент /// </summary> public static IRestHttpClient GetRestClient(IHostConfigurationDomain hostConfiguration) => GetRestClient(hostConfiguration, String.Empty);