/// <summary>
        /// Adds <see cref="IHttpService"/> as <see cref="HttpService"/> to the container with interception and configuration
        /// </summary>
        public static IContainer AddHttp(this IContainer container, IHttpInterceptor httpInterceptor, Action <HttpSettings> config = null)
        {
            container.ConfigureHttp(config)
            .AddSingleton <IHttpService, HttpService>();

            container.AddSingleton(httpInterceptor);

            return(container);
        }
Example #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public HttpService(IJsonService jsonService, ILoggingService loggingService, IHttpInterceptor httpInterceptor, HttpSettings httpSettings)
        {
            this.client = new HttpClient();
            this.Configure(httpSettings);

            // Timeout can be configured only once during the lifetime
            this.client.Timeout = TimeSpan.FromMilliseconds(httpSettings.Timeout);

            this.jsonService     = jsonService;
            this.loggingService  = loggingService;
            this.httpInterceptor = httpInterceptor;
            this.httpSettings    = httpSettings;
        }
Example #3
0
 public void AddInterceptor(IHttpInterceptor interceptor)
 {
     _interceptors.Add(interceptor);
 }
Example #4
0
 public CallAnApi WhichRequestsInterceptedBy(IHttpInterceptor interceptor)
 {
     this._interceptors.Add(interceptor);
     return(this);
 }