Exemplo n.º 1
0
        /// <summary>
        /// Run DCC record and playback reverse proxy server.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="options">Options for overriding the defaults of DCC</param>
        public static void RunDcc(this IApplicationBuilder app, DccOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            app.UseMiddleware <DccMiddleware>(Options.Create(options));
        }
Exemplo n.º 2
0
        // ReSharper disable once UnusedParameter.Local
        public DccMiddleware(RequestDelegate next, IOptions <DccOptions> options, ILoggerFactory loggerFactory)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _options = options.Value;

            if (string.IsNullOrEmpty(_options.Host))
            {
                throw new ArgumentException("Options parameter must specify host.", nameof(options));
            }

            _httpClient = new HttpClient(_options.BackChannelMessageHandler ?? new HttpClientHandler());

            _logger = loggerFactory.CreateLogger <DccMiddleware>();
        }