Example #1
0
 public HttpPeer(string hostAndPort, HttpClient httpClient, IBaseUrlFinder finder, IOcelotConfiguration config, IIdentityServerConfiguration identityServerConfiguration)
 {
     _identityServerConfiguration = identityServerConfiguration;
     _config                 = config;
     Id                      = hostAndPort;
     _hostAndPort            = hostAndPort;
     _httpClient             = httpClient;
     _jsonSerializerSettings = new JsonSerializerSettings()
     {
         TypeNameHandling = TypeNameHandling.All
     };
     _baseSchemeUrlAndPort = finder.Find();
 }
Example #2
0
        public Placeholders(IBaseUrlFinder finder, IRequestScopedDataRepository repo, IHttpContextAccessor httpContextAccessor)
        {
            _repo = repo;
            _httpContextAccessor = httpContextAccessor;
            _finder       = finder;
            _placeholders = new Dictionary <string, Func <Response <string> > >
            {
                { "{BaseUrl}", GetBaseUrl() },
                { "{TraceId}", GetTraceId() },
                { "{RemoteIpAddress}", GetRemoteIpAddress() }
            };

            _requestPlaceholders = new Dictionary <string, Func <DownstreamRequest, string> >
            {
                { "{DownstreamBaseUrl}", GetDownstreamBaseUrl() }
            };
        }
Example #3
0
        public FilePeersProvider(IOptions <FilePeers> options, IBaseUrlFinder finder, IOcelotConfigurationProvider provider, IIdentityServerConfiguration identityServerConfig)
        {
            _identityServerConfig = identityServerConfig;
            _provider             = provider;
            _finder  = finder;
            _options = options;
            _peers   = new List <IPeer>();
            //todo - sort out async nonsense..
            var config = _provider.Get().GetAwaiter().GetResult();

            foreach (var item in _options.Value.Peers)
            {
                var httpClient = new HttpClient();
                //todo what if this errors?
                var httpPeer = new HttpPeer(item.HostAndPort, httpClient, _finder, config.Data, _identityServerConfig);
                _peers.Add(httpPeer);
            }
        }
Example #4
0
        public FilePeersProvider(IOptions <FilePeers> options, IBaseUrlFinder finder, IInternalConfigurationRepository repo, IIdentityServerConfiguration identityServerConfig)
        {
            _identityServerConfig = identityServerConfig;
            _repo    = repo;
            _finder  = finder;
            _options = options;
            _peers   = new List <IPeer>();

            var config = _repo.Get();

            foreach (var item in _options.Value.Peers)
            {
                var httpClient = new HttpClient();

                //todo what if this errors?
                var httpPeer = new HttpPeer(item.HostAndPort, httpClient, _finder, config.Data, _identityServerConfig);
                _peers.Add(httpPeer);
            }
        }
 public HeaderFindAndReplaceCreator(IBaseUrlFinder finder)
 {
     _finder       = finder;
     _placeholders = new Dictionary <string, Func <string> >();
     _placeholders.Add("{BaseUrl}", () => _finder.Find());
 }