public DefaultUnleashApiClientFactory(UnleashSettings settings, IHttpClientFactory httpClientFactory,
                                       IJsonSerializer jsonSerializer, UnleashApiClientRequestHeaders unleashApiClientRequestHeaders)
 {
     this.settings          = settings;
     this.httpClientFactory = httpClientFactory;
     this.jsonSerializer    = jsonSerializer;
     this.unleashApiClientRequestHeaders = unleashApiClientRequestHeaders;
 }
Ejemplo n.º 2
0
 public UnleashApiClient(
     HttpClient httpClient,
     IJsonSerializer jsonSerializer,
     UnleashApiClientRequestHeaders clientRequestHeaders)
 {
     this.httpClient           = httpClient;
     this.jsonSerializer       = jsonSerializer;
     this.clientRequestHeaders = clientRequestHeaders;
 }
        private static void SetRequestHeaders(HttpRequestMessage requestMessage, UnleashApiClientRequestHeaders headers)
        {
            const string appNameHeader    = "UNLEASH-APPNAME";
            const string instanceIdHeader = "UNLEASH-INSTANCEID";

            requestMessage.Headers.TryAddWithoutValidation(appNameHeader, headers.AppName);
            requestMessage.Headers.TryAddWithoutValidation(instanceIdHeader, headers.InstanceTag);

            SetCustomHeaders(requestMessage, headers.CustomHttpHeaders);
            SetCustomHeaders(requestMessage, headers.CustomHttpHeaderProvider?.CustomHeaders);
        }
 public UnleashApiClient(
     HttpClient httpClient,
     IJsonSerializer jsonSerializer,
     UnleashApiClientRequestHeaders clientRequestHeaders,
     string projectId = null)
 {
     this.httpClient           = httpClient;
     this.jsonSerializer       = jsonSerializer;
     this.clientRequestHeaders = clientRequestHeaders;
     this.projectId            = projectId;
 }
Ejemplo n.º 5
0
        internal static void SetRequestHeaders(HttpRequestMessage requestMessage, UnleashApiClientRequestHeaders headers)
        {
            requestMessage.Headers.TryAddWithoutValidation(AppNameHeader, headers.AppName);
            requestMessage.Headers.TryAddWithoutValidation(InstanceIdHeader, headers.InstanceTag);

            if (headers.CustomHttpHeaders == null)
            {
                return;
            }

            if (headers.CustomHttpHeaders.Count == 0)
            {
                return;
            }

            foreach (var header in headers.CustomHttpHeaders)
            {
                requestMessage.Headers.TryAddWithoutValidation(header.Key, header.Value);
            }
        }
Ejemplo n.º 6
0
        private static void SetRequestHeaders(HttpRequestMessage requestMessage, UnleashApiClientRequestHeaders headers)
        {
            const string appNameHeader    = "UNLEASH-APPNAME";
            const string instanceIdHeader = "UNLEASH-INSTANCEID";

            requestMessage.Headers.TryAddWithoutValidation(appNameHeader, headers.AppName);
            requestMessage.Headers.TryAddWithoutValidation(instanceIdHeader, headers.InstanceTag);

            if (headers.CustomHttpHeaders == null)
            {
                return;
            }

            if (headers.CustomHttpHeaders.Count == 0)
            {
                return;
            }

            foreach (var header in headers.CustomHttpHeaders)
            {
                requestMessage.Headers.TryAddWithoutValidation(header.Key, header.Value);
            }
        }