/// <inheritdoc />
        public FluentHttpClientBuilder CreateClient(string identifier)
        {
            // todo: make configurable
            var id = DefaultSubClientIdentityFormatter(Identifier, identifier);

            return(_clientFactory.CreateBuilder(id)
                   .FromOptions(_options)
                   .WithIdentifier(id));
        }
        /// <summary>
        /// Add/register HTTP client from options.
        /// </summary>
        /// <param name="factory"></param>
        /// <param name="options">options to register.</param>
        /// <returns>Returns HTTP client created.</returns>
        public static IFluentHttpClient Add(this IFluentHttpClientFactory factory, FluentHttpClientOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var builder = factory.CreateBuilder(options.Identifier)
                          .FromOptions(options);

            return(factory.Add(builder));
        }
Пример #3
0
        private void SetupHttp()
        {
            _fluentHttpClientFactory.CreateBuilder("auth")
            // shared
            .WithHeader("user-agent", "slabs-testify")
            .WithHeader("locale", "en-GB")
            .WithTimeout(5)
            .UseTimer()
            .UseMiddleware <LoggerHttpMiddleware>()

            // auth
            //.WithBaseUrl("http://staging.api.cpm-odin.com:1001")
            .WithBaseUrl("http://localhost:2001")
            .Register()

            // common
            .WithIdentifier("common")
            .WithBaseUrl("http://staging.api.cpm-odin.com:1002")
            .Register();
        }
 /// <inheritdoc />
 public FluentHttpClientBuilder CreateClient(string identifier)
 {
     return(_clientFactory.CreateBuilder(identifier)
            .FromOptions(_options));
 }