예제 #1
0
 public static void OnConditionRetry(this IHttpMiddlewareDescriptor descriptor, int retrycount, Func <HttpResponse, bool> retrycondition, Action <DelegateResult <HttpResponse>, int> onretry = null)
 {
     descriptor.Add <OnConditionRetryMiddelware>(x => {
         x.Add(OnConditionRetryMiddelware.RETRY_COUNT_KEY, retrycount);
         x.Add(OnConditionRetryMiddelware.RETRY_CONDITION_KEY, retrycondition);
         if (onretry != null)
         {
             x.Add(OnConditionRetryMiddelware.ON_RETRY_KEY, onretry);
         }
     });
 }
 public static void UseMemoryCache(this IHttpMiddlewareDescriptor descriptor, double durationinseconds, Func <HttpRequest, string> keybuilder, Func <HttpResponse, bool> cachewhen, string cachemode = "sliding", Action <HttpResponseMessage> oncacheget = null)
 {
     descriptor.Add <MemoryCacheMiddleware>(y =>
     {
         y.Add(MemoryCacheMiddleware.CACHE_DURATION_IN_SECONDS_KEY, durationinseconds);
         y.Add(MemoryCacheMiddleware.CACHE_KEY_BUILDER_KEY, keybuilder);
         y.Add(MemoryCacheMiddleware.CACHE_MODE_KEY, cachemode);
         y.Add(MemoryCacheMiddleware.CACHE_WHEN_KEY, cachewhen);
         if (oncacheget != null)
         {
             y.Add(MemoryCacheMiddleware.ON_CACHE_GET, oncacheget);
         }
     });
 }
예제 #3
0
 public static void UseTimeout(this IHttpMiddlewareDescriptor descriptor, int timeoutdurationinseconds = 10)
 {
     descriptor.Add <TimeoutMiddelware>(x => {
         x.Add(TimeoutMiddelware.TIMEOUT_DURATION_IN_SECONDS_KEY, timeoutdurationinseconds);
     });
 }
예제 #4
0
 public static void UseCircuitBreaker(this IHttpMiddlewareDescriptor descriptor, AsyncCircuitBreakerPolicy <HttpResponse> policy)
 {
     descriptor.Add <CircuitBreakerMiddelware>(x => {
         x.Add(CircuitBreakerMiddelware.CIRCUIT_BREAKER_POLICY_KEY, policy);
     });
 }
예제 #5
0
 public static void UseSerilog(this IHttpMiddlewareDescriptor descriptor)
 {
     descriptor.Add <SerilogMiddelware>();
 }
 public static void UseCommonLogging(this IHttpMiddlewareDescriptor descriptor)
 {
     descriptor.Add <CommonLoggingMiddelware>();
 }
예제 #7
0
 public static void UseApplicationInsights(this IHttpMiddlewareDescriptor descriptor)
 {
     descriptor.Add <ApplicationInsightsMiddelware>();
 }
 public static void AuthorizedByBearerToken(this IHttpMiddlewareDescriptor descriptor, string tokenvalue)
 {
     descriptor.Add <TokenAuthenticatorMiddleware>(y => { y.Add(TokenAuthenticatorMiddleware.TOKEN_VALUE_KEY, tokenvalue); y.Add(TokenAuthenticatorMiddleware.TOKEN_TYPE_KEY, "Bearer"); });
 }
 public static void AuthorizedByBasicHttp(this IHttpMiddlewareDescriptor descriptor, string username, string password)
 {
     descriptor.Add <BasicHttpAuthenticatorMiddleware>(y => { y.Add(BasicHttpAuthenticatorMiddleware.USER_NAME_KEY, username); y.Add(BasicHttpAuthenticatorMiddleware.PASSWORD_KEY, password); });
 }
 public static void AddTracing(this IHttpMiddlewareDescriptor descriptor, string requestidheadername = "requestid", string parentidheadername = "parentid", string operationidheadername = "operationid")
 {
     descriptor.Add <TracingMiddleware>(y => { y.Add(TracingMiddleware.REQUESTID_HEADER_NAME_KEY, requestidheadername); y.Add(TracingMiddleware.PARENTID_HEADER_NAME_KEY, parentidheadername); y.Add(TracingMiddleware.OPERATIONID_HEADER_NAME_KEY, operationidheadername); });
 }