示例#1
0
        public LinkGenerator(IPersister persister, ConnectionMonitor connection, CacheWrapper cacheWrapper, IRequestLogger logger)
        {
            _logger = logger;

            // DON'T USE DISTRIBUTED CACHE FOR N2 internal data 
            // _urlCache = cacheService.GetCache<string>(new CacheConfig("LinkGenerator_urlCache", 1800));
            _urlCache = new HttpRuntimeCacheWrapper<string>("LinkGenerator_urlCache", cacheWrapper);
            _itemCache = new HttpRuntimeCacheWrapper<object>("LinkGenerator_urlCache_item", cacheWrapper);

            // hook up to persister events
            connection.Online += delegate
            {
                persister.ItemSaved += persister_ItemSaved;
                persister.ItemMoving += persister_ItemMoving;
                persister.ItemMoved += persister_ItemMoved;
                persister.ItemCopied += persister_ItemCopied;
                persister.ItemDeleted += persister_ItemDeleted;
                persister.FlushCache += persister_ItemInvalidated;
            };
            connection.Offline += delegate
            {
                persister.ItemSaved -= persister_ItemSaved;
                persister.ItemMoving -= persister_ItemMoving;
                persister.ItemMoved -= persister_ItemMoved;
                persister.ItemCopied -= persister_ItemCopied;
                persister.ItemDeleted -= persister_ItemDeleted;
                persister.FlushCache -= persister_ItemInvalidated;
            };
        }
示例#2
0
        public async Task InvokeAsync(HttpContext context, IRequestLogger logger)
        {
            context.Request.EnableBuffering();
            if (context.Request != null)
            {
                string path        = context.Request.Path;
                var    method      = context.Request.Method;
                var    queryString = context.Request.QueryString.ToString();

                string bodyString;
                using (var reader = new StreamReader(context.Request.Body, Encoding.UTF8, true, 1024, true))
                {
                    bodyString = await reader.ReadToEndAsync();
                }

                context.Request.Body.Seek(0, SeekOrigin.Begin);

                logger.Log(method, path, queryString, bodyString);
            }

            if (_next != null)
            {
                await _next(context);
            }
        }
示例#3
0
 public Client(IRequestLogger loger, chz.WindowsServices.Setting.ISettingProvider setting)
 {
     encoding     = Encoding.UTF8;
     httpClient   = new HttpClient();
     this.loger   = loger;
     this.setting = setting;
 }
示例#4
0
 public CandyRackPartController(IRequestLogger logger, IOffersViewModelBuilder offersViewModelBuilder, ICartApi cartApi, ILinkGenerator linkGenerator)
     : base(logger, null, null)
 {
     _offersViewModelBuilder = offersViewModelBuilder;
     _cartApi       = cartApi;
     _linkGenerator = linkGenerator;
 }
示例#5
0
        public LinkGenerator(IPersister persister, ConnectionMonitor connection, CacheWrapper cacheWrapper, IRequestLogger logger)
        {
            _logger = logger;

            // DON'T USE DISTRIBUTED CACHE FOR N2 internal data
            // _urlCache = cacheService.GetCache<string>(new CacheConfig("LinkGenerator_urlCache", 1800));
            _urlCache  = new HttpRuntimeCacheWrapper <string>("LinkGenerator_urlCache", cacheWrapper);
            _itemCache = new HttpRuntimeCacheWrapper <object>("LinkGenerator_urlCache_item", cacheWrapper);

            // hook up to persister events
            connection.Online += delegate
            {
                persister.ItemSaved   += persister_ItemSaved;
                persister.ItemMoving  += persister_ItemMoving;
                persister.ItemMoved   += persister_ItemMoved;
                persister.ItemCopied  += persister_ItemCopied;
                persister.ItemDeleted += persister_ItemDeleted;
                persister.FlushCache  += persister_ItemInvalidated;
            };
            connection.Offline += delegate
            {
                persister.ItemSaved   -= persister_ItemSaved;
                persister.ItemMoving  -= persister_ItemMoving;
                persister.ItemMoved   -= persister_ItemMoved;
                persister.ItemCopied  -= persister_ItemCopied;
                persister.ItemDeleted -= persister_ItemDeleted;
                persister.FlushCache  -= persister_ItemInvalidated;
            };
        }
示例#6
0
 public HomeController(IOptions <SetlistConfig> config, ILogger <HomeController> log, ISetlistBuilder setlistBuilder, ISpotifyService spotifyService, IRequestLogger requestLogger)
 {
     _config         = config;
     _log            = log;
     _setlistBuilder = setlistBuilder;
     _spotifyService = spotifyService;
     _requestLogger  = requestLogger;
 }
示例#7
0
        public SpotifyService(IHttpContextAccessor httpContextAccessor, IRequestLogger requestLogger)
        {
            _httpContextAccessor = httpContextAccessor;
            _requestLogger       = requestLogger;

            _client = new HttpClient();

            _client.BaseAddress = new Uri("https://api.spotify.com/v1");
        }
 public ShoppingCartController(ICartApi cartApi, IRequestLogger logger, ILinkGenerator linkGenerator,
                               IPageInfo pageInfo, IOffersViewModelBuilder offersViewModelBuilder, IShoppingCartViewModelBuilder shoppingCartViewModelBuilder, ICatalogApi catalogApi)
     : base(logger, linkGenerator, catalogApi)
 {
     CartApi = cartApi;
     ShoppingCartViewModelBuilder = shoppingCartViewModelBuilder;
     PageInfo = pageInfo;
     OffersViewModelBuilder = offersViewModelBuilder;
 }
示例#9
0
 public RequestHandler(
     IRedirectHandler redirectHandler,
     IRequestLogger requestLogger,
     IConfiguration configuration)
 {
     _configuration   = configuration ?? throw new ArgumentNullException(nameof(configuration));
     _requestLogger   = requestLogger ?? throw new ArgumentNullException(nameof(requestLogger));
     _redirectHandler = redirectHandler ?? throw new ArgumentNullException(nameof(redirectHandler));
 }
示例#10
0
 public ShoppingCartPartController(IRequestLogger logger, ICartApi cartApi, IShoppingCartViewModelBuilder shoppingCartViewModelBuilder,
                                   IOffersViewModelBuilder offersViewModelBuilder, ILinkGenerator linkGenerator)
     : base(logger)
 {
     _shoppingCartViewModelBuilder = shoppingCartViewModelBuilder;
     _cartApi = cartApi;
     _offersViewModelBuilder = offersViewModelBuilder;
     _linkGenerator          = linkGenerator;
 }
 public CatalogController(IRequestLogger logger, ICategoryViewModelBuilder catViewModelBuilder,
                          ILinkGenerator linkGenerator,
                          IPageInfo pageInfo, ICatalogApi catalogApi)
     : base(logger, linkGenerator, catalogApi)
 {
     _pageInfo            = pageInfo;
     _linkGenerator       = linkGenerator;
     _catViewModelBuilder = catViewModelBuilder;
 }
 /// <summary>
 /// </summary>
 /// <param name="baseUrl"></param>
 /// <param name="requestHandler"></param>
 /// <param name="requestLogger"></param>
 protected AbstractRestClient(string baseUrl, IRequestHandler requestHandler, IRequestLogger requestLogger)
 {
     RequestLogger = requestLogger;
     RequestHandler = requestHandler;
     BaseUrl = baseUrl;
     RequestHeaders = new Dictionary<string, string>();
     ConnectionTimeout = 2000; //Default 2s, deliberately short.
     ReadWriteTimeout = 8000; // Default 8s, reasonably short if accidentally called from the UI thread
 }
 /// <summary>
 /// </summary>
 /// <param name="baseUrl"></param>
 /// <param name="requestHandler"></param>
 /// <param name="requestLogger"></param>
 protected AbstractRestClient(string baseUrl, IRequestHandler requestHandler, IRequestLogger requestLogger)
 {
     RequestLogger     = requestLogger;
     RequestHandler    = requestHandler;
     BaseUrl           = baseUrl;
     RequestHeaders    = new Dictionary <string, string>();
     ConnectionTimeout = 2000; //Default 2s, deliberately short.
     ReadWriteTimeout  = 8000; // Default 8s, reasonably short if accidentally called from the UI thread
 }
 public LogCommandHandlerDecorator(IRequestLogger requestLogger,
                                   ICommandHandler <TCommand> decoratedRequestHandler,
                                   IOptionsSnapshot <LogSettings> logSettingsOption,
                                   ILogger <TCommand> logger)
 {
     this.requestLogger           = requestLogger;
     this.decoratedRequestHandler = decoratedRequestHandler;
     this.logger      = logger;
     this.logSettings = logSettingsOption.Value;
 }
示例#15
0
        public StactiveMiddleware(
            RequestDelegate next,
            IRequestLogger requestLogger,
            ILogger <StactiveMiddleware> logger)
        {
            _next   = next;
            _logger = logger;

            _requestLogger = requestLogger;
        }
示例#16
0
 public LogQueryHandlerDecorator(IRequestLogger requestLogger,
                                 IQueryHandler <TQuery, TResponse> decoratedRequestHandler,
                                 IOptionsSnapshot <LogSettings> logSettingsOption,
                                 ILogger <TQuery> logger)
 {
     this.requestLogger           = requestLogger;
     this.decoratedRequestHandler = decoratedRequestHandler;
     this.logger      = logger;
     this.logSettings = logSettingsOption.Value;
 }
示例#17
0
 public LogCommandHandlerDecorator(IRequestLogger requestLogger,
                                   ICommandHandler <TCommand> decoratedRequestHandler,
                                   LogSettings logSettings,
                                   ILogger <TCommand> logger)
 {
     this.requestLogger           = requestLogger;
     this.decoratedRequestHandler = decoratedRequestHandler;
     this.logger      = logger;
     this.logSettings = logSettings;
 }
示例#18
0
 public LogQueryHandlerDecorator(IRequestLogger requestLogger,
                                 IQueryHandler <TQuery, TResponse> decoratedRequestHandler,
                                 LogSettings logSettings,
                                 ILogger <TQuery> logger)
 {
     this.requestLogger           = requestLogger;
     this.decoratedRequestHandler = decoratedRequestHandler;
     this.logger      = logger;
     this.logSettings = logSettings;
 }
示例#19
0
        private static Action <NancyContext> GetLogRequestHook(IRequestLogger requestLogger)
        {
            return(ctx =>
            {
                var requestData = ExtractRequestData(ctx.Request);
                var responseData = ExtractResponseData(ctx.Response);

                requestLogger.Log(requestData, responseData);
            });
        }
        public RequestLogViewModel(IRequestLogger requestLogger)
        {
            Requires.NotNull(requestLogger, "requestLogger");
            _requestLogger = requestLogger;

            _lazyUpdateCommand = new Lazy<ICommand>(() => new RelayCommand(OnUpdate));

            _logEntriesSource = new ObservableCollection<RequestLogEntry>();
            _logEntries = new ListCollectionView(_logEntriesSource);
            _logEntries.SortDescriptions.Add(new SortDescription("Created", ListSortDirection.Descending));
        }
示例#21
0
        private static Func <NancyContext, Exception, dynamic> GetLogErrorHook(IRequestLogger requestLogger)
        {
            return((ctx, ex) =>
            {
                var requestData = ExtractRequestData(ctx.Request);
                var responseData = ExtractResponseData(ctx.Response);

                requestLogger.LogError(requestData, responseData, ex);

                return ctx.Response;
            });
        }
示例#22
0
 public ASHttpModule(ISettingManager settingManager,
                     IContextProvider httpContextProvider,
                     ILogger logger,
                     IRequestLogger requestLogger,
                     IGeoProvider geoProvider)
 {
     this._settingManager      = settingManager;
     this._geoProvider         = geoProvider;
     this._requestLogger       = requestLogger;
     this._httpContextProvider = httpContextProvider;
     this._logger = logger;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpLogger"/> class.
 /// </summary>
 /// <param name="logger">Actual logger instance to use as writer.</param>
 /// <param name="requestLogger">Request detail logger.</param>
 /// <param name="responseLogger">Response detail logger.</param>
 /// <param name="basicInfoLogger">Basic information logger.</param>
 /// <param name="requestPredicates">Request path predicates to determine is the log message required.</param>
 public HttpLogger(
     ILogger logger,
     IRequestLogger requestLogger,
     IResponseLogger responseLogger,
     IBasicInfoLogger basicInfoLogger,
     IEnumerable <IHttpRequestPredicate> requestPredicates)
 {
     _logger            = logger;
     _requestLogger     = requestLogger;
     _responseLogger    = responseLogger;
     _basicInfoLogger   = basicInfoLogger;
     _requestPredicates = requestPredicates;
 }
示例#24
0
 public RequestHandlerTests()
 {
     _redirectHandler = A.Fake <IRedirectHandler>();
     _requestLogger   = A.Fake <IRequestLogger>();
     _configuration   = A.Fake <IConfiguration>();
     _sut             = A.Fake <RequestHandler>(
         o => o.WithArgumentsForConstructor(new object[] { _redirectHandler, _requestLogger, _configuration })
         .CallsBaseMethods());
     _httpContext = new FakeHttpContext();
     _httpContext.Response.StatusCode = 404;
     WhenIsRemote();
     WhenIsNotResourceFile();
 }
示例#25
0
 public ClientController(IBackendCommunication backendCommunication, ILogger logger, ILinkRepository linkRepository, IRequestLogger requestLogger,
                         IHttpResponseMessageBuilder httpResponseMessageBuilder, IOnPremiseRequestBuilder onPremiseRequestBuilder, IPathSplitter pathSplitter,
                         ITraceManager traceManager)
 {
     _backendCommunication = backendCommunication;
     _logger                     = logger;
     _linkRepository             = linkRepository;
     _requestLogger              = requestLogger;
     _httpResponseMessageBuilder = httpResponseMessageBuilder;
     _onPremiseRequestBuilder    = onPremiseRequestBuilder;
     _pathSplitter               = pathSplitter;
     _traceManager               = traceManager;
 }
 protected void CreateLog(HttpContext context, IRequestLogger requestLogger, string requestBody,
                          string responseBody)
 {
     requestLogger.LogRequest(
         clientAddress: GetClientAddress(context),
         requestUrl: GetUrl(context),
         requestMethod: context.Request.Method,
         requestHeaders: context.Request.Headers,
         requestBody: requestBody,
         responseStatus: context.Response.StatusCode.ToString(),
         responseHeaders: context.Response.Headers,
         responseBody: responseBody);
 }
示例#27
0
 public WebhookResponseHandler(
     IEventHandlerFactory eventHandlerFactory,
     IHttpClientFactory httpClientFactory,
     IRequestBuilder requestBuilder,
     IAuthenticationHandlerFactory authenticationHandlerFactory,
     IRequestLogger requestLogger,
     IBigBrother bigBrother,
     SubscriberConfiguration subscriberConfiguration)
     : base(httpClientFactory, authenticationHandlerFactory, requestBuilder, requestLogger, bigBrother, subscriberConfiguration)
 {
     _eventHandlerFactory     = eventHandlerFactory;
     _subscriberConfiguration = subscriberConfiguration;
 }
示例#28
0
        public RequestLoggerMiddleware(RequestDelegate next, RequestLoggerOptions options = null)
        {
            _next    = next;
            _options = options ?? new RequestLoggerOptions();

            if (_options.ShouldUseColor && !Console.IsOutputRedirected)
            {
                _logger = new ColorfulRequestLogger(_next);
            }
            else
            {
                _logger = new PlainRequestLogger(_next);
            }
        }
 public ClientController(IBackendCommunication backendCommunication, ILogger logger, ILinkRepository linkRepository, IRequestLogger requestLogger,
                         IOnPremiseRequestBuilder onPremiseRequestBuilder, IPathSplitter pathSplitter,
                         ITraceManager traceManager, IInterceptorManager interceptorManager, IPostDataTemporaryStore postDataTemporaryStore)
 {
     _backendCommunication = backendCommunication ?? throw new ArgumentNullException(nameof(backendCommunication));
     _logger                  = logger;
     _linkRepository          = linkRepository ?? throw new ArgumentNullException(nameof(linkRepository));
     _requestLogger           = requestLogger ?? throw new ArgumentNullException(nameof(requestLogger));
     _onPremiseRequestBuilder = onPremiseRequestBuilder ?? throw new ArgumentNullException(nameof(onPremiseRequestBuilder));
     _pathSplitter            = pathSplitter ?? throw new ArgumentNullException(nameof(pathSplitter));
     _traceManager            = traceManager ?? throw new ArgumentNullException(nameof(traceManager));
     _interceptorManager      = interceptorManager ?? throw new ArgumentNullException(nameof(interceptorManager));
     _postDataTemporaryStore  = postDataTemporaryStore ?? throw new ArgumentNullException(nameof(postDataTemporaryStore));
 }
 public GenericWebhookHandler(
     IHttpClientFactory httpClientFactory,
     IAuthenticationHandlerFactory authenticationHandlerFactory,
     IRequestBuilder requestBuilder,
     IRequestLogger requestLogger,
     IBigBrother bigBrother,
     WebhookConfig webhookConfig)
 {
     BigBrother     = bigBrother;
     RequestBuilder = requestBuilder;
     _requestLogger = requestLogger;
     WebhookConfig  = webhookConfig;
     _authenticationHandlerFactory = authenticationHandlerFactory;
     HttpClientFactory             = httpClientFactory;
 }
示例#31
0
        public static void Enable(INancyModule module, IRequestLogger requestLogger)
        {
            if (module == null)
            {
                throw new ArgumentNullException("module");
            }

            if (requestLogger == null)
            {
                throw new ArgumentNullException("requestLogger");
            }

            module.After.AddItemToEndOfPipeline(GetLogRequestHook(requestLogger));
            module.OnError.AddItemToEndOfPipeline(GetLogErrorHook(requestLogger));
        }
        public ContentControllerBase(IRequestLogger logger, ILinkGenerator linkGenerator, ICatalogApi catalogApi)
        {
            _catalogApi = catalogApi;

            Logger        = logger;
            LinkGenerator = linkGenerator;

#if SAVE_VIEW_MODEL
            _saveVmDir = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/SavedViewModels");
            if (!Directory.Exists(_saveVmDir))
            {
                Directory.CreateDirectory(_saveVmDir);
            }
#endif
        }
示例#33
0
        public static void Enable(IPipelines pipelines, IRequestLogger requestLogger)
        {
            if (pipelines == null)
            {
                throw new ArgumentNullException("pipelines");
            }

            if (requestLogger == null)
            {
                throw new ArgumentNullException("requestLogger");
            }

            pipelines.AfterRequest.AddItemToEndOfPipeline(GetLogRequestHook(requestLogger));
            pipelines.OnError.AddItemToEndOfPipeline(GetLogErrorHook(requestLogger));
        }
        public BaseRequestCacheManager(string name, ICache<string, byte[]> cache, IHttpParser parser, IRequestLogger requestLogger)
        {
            Requires.NotNull(name, "name");
            Requires.NotNullOrEmpty<ArgumentException>(name);
            Requires.NotNullOrWhiteSpace<ArgumentException>(name);
            _name = name;

            Requires.NotNull(cache, "cache");
            _cache = cache;

            Requires.NotNull(parser, "parser");
            _parser = parser;

            Requires.NotNull(requestLogger, "requestLogger");
            _requestLogger = requestLogger;
        }
        public HttpProxyHandlerFactory(IHttpParser parser, IHttpRequestSender requestSender, IHashProvider hashProvider, ICache<string, byte[]> cache, IRequestLogger requestLogger)
        {
            Requires.NotNull(parser, "parser");
            _parser = parser;

            Requires.NotNull(requestSender, "requestSender");
            _requestSender = requestSender;

            Requires.NotNull(hashProvider, "hashProvider");
            _hashProvider = hashProvider;

            Requires.NotNull(cache, "cache");
            _cache = cache;

            Requires.NotNull(requestLogger, "requestLogger");
            _requestLogger = requestLogger;
        }
 public RecursiveZonePartsAdapterBase(IRequestLogger logger)
     : this(logger, null)
 {
 }
 public RecursiveZonePartsAdapterBase(IRequestLogger logger, ICatalogApi catalogApi)
 {
     _logger = logger;
     _catalogApi = catalogApi;
 }
 /// <summary>
 /// The Constructor with the Logger parameter. 
 /// </summary>
 /// <param name="log"></param>
 public EmployeeInfoController(IRequestLogger log)
 {
     objDs = new DataAccess();
     logger = log;
 }
 public EmployeeInfoController()
 {
     objDs = new DataAccess();
     logger = new RequestLogger();
 }
 public ListOfLinksAdapter(ILinkGenerator linkGenerator, ICatalogApi catalogApi, IRequestLogger logger)
     : base(logger, catalogApi)
 {
     _linkGenerator = linkGenerator;
 }
示例#41
0
 public static void RemoveRequestLogger(IRequestLogger requestLogger)
 {
     RemoveRequestLogger(requestLogger.RequestId);
 }
 /// <summary>
 /// The Constructor with the Logger parameter. 
 /// </summary>
 /// <param name="log"></param>
 public XmlController(IRequestLogger log)
 {
     logger = log;
 }
示例#43
0
 public static void AddRequestLogger(IRequestLogger requestLogger)
 {
     AddRequestLogger(requestLogger.RequestId, requestLogger);
 }
示例#44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JsonRestServices"/> class with the specified
 /// logger, retry logic, URI builder, and string serializer.
 /// </summary>
 /// <param name="logger">The logger to use for requests. Specify <c>null</c> if requests do not need to be logged.</param>
 /// <param name="retryLogic">The retry logic to use for REST operations.</param>
 /// <param name="urlBuilder">The URL builder to use for constructing URLs with query parameters.</param>
 /// <param name="stringSerializer">The string serializer to use for requests from this service.</param>
 /// <exception cref="ArgumentNullException">
 /// If <paramref name="retryLogic"/> is <c>null</c>.
 /// <para>-or-</para>
 /// <para>If <paramref name="urlBuilder"/> is <c>null</c>.</para>
 /// <para>-or-</para>
 /// <para>If <paramref name="stringSerializer"/> is <c>null</c>.</para>
 /// </exception>
 public JsonRestServices(IRequestLogger logger, IRetryLogic<Response, HttpStatusCode> retryLogic, IUrlBuilder urlBuilder, IStringSerializer stringSerializer)
     : base(stringSerializer, logger, retryLogic, urlBuilder)
 {
 }
示例#45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JsonRestServices"/> class with the specified
 /// request logger and the default JSON string serializer and URL builder.
 /// </summary>
 /// <param name="requestLogger">The logger to use for requests. Specify <c>null</c> if requests do not need to be logged.</param>
 public JsonRestServices(IRequestLogger requestLogger)
     : this(requestLogger, new RequestRetryLogic(), new UrlBuilder(), new JsonStringSerializer())
 {
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="logger">The http request logger</param>
 public BasicRequestHandler(IRequestLogger logger)
 {
     Logger = logger;
 }
示例#47
0
        public HttpProxyHandler(IPAddress address, int port, IHttpParser parser, IHttpRequestSender requestSender, IHashProvider hashProvider, ICache<string, byte[]> cache, IRequestLogger requestLogger)
        {
            Requires.NotNull(parser, "parser");
            _parser = parser;

            Requires.NotNull(requestSender, "requestSender");
            _requestSender = requestSender;

            Requires.NotNull(hashProvider, "hashProvider");
            _hashProvider = hashProvider;

            Requires.NotNull(cache, "cache");
            _cache = cache;

            Requires.NotNull(requestLogger, "requestLogger");
            _requestLogger = requestLogger;

            _listener = new TcpListener(address, port);
            // _clientQueue = new ActionQueue<TcpClient>(Handle);

            _tokenSource = new CancellationTokenSource();
            _workingTask = new Task(Run, Token, TaskCreationOptions.LongRunning);
            _waitHandle = new AutoResetEvent(false);

            _enableCache = true;

        }
 public IsolatedStorageCacheManager(IsolatedStorageCache<string, byte[]> cache, IHttpParser parser, IRequestLogger requestLogger)
     : base("Isolated Storage Cache", cache, parser, requestLogger)
 {
 }
示例#49
0
 public static void AddRequestLogger(Guid requestId, IRequestLogger requestLogger)
 {
     _requestLoggers.TryAdd(requestId, requestLogger);
 }
 public MemoryRequestCacheManager(MemoryCache<string, byte[]> cache, IHttpParser parser, IRequestLogger requestLogger)
     : base("Memory Cache", cache, parser, requestLogger)
 {
 }
 public XmlController()
 {
     logger = new RequestLogger();
 }