/// <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); }
/// <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; }
public void AddInterceptor(IHttpInterceptor interceptor) { _interceptors.Add(interceptor); }
public CallAnApi WhichRequestsInterceptedBy(IHttpInterceptor interceptor) { this._interceptors.Add(interceptor); return(this); }