Example #1
0
        public Placeholders(IBaseUrlFinder finder, IRequestScopedDataRepository repo)
        {
            _repo = repo;
            _finder = finder;
            _placeholders = new Dictionary<string, Func<Response<string>>>();
            _placeholders.Add("{BaseUrl}", () => new OkResponse<string>(_finder.Find()));
            _placeholders.Add("{TraceId}", () => {
                var traceId = _repo.Get<string>("TraceId");
                if(traceId.IsError)
                {
                    return new ErrorResponse<string>(traceId.Errors);
                }

                return new OkResponse<string>(traceId.Data);
            });

            _requestPlaceholders = new Dictionary<string, Func<HttpRequestMessage, string>>();
            _requestPlaceholders.Add("{DownstreamBaseUrl}", x => {
                var downstreamUrl = $"{x.RequestUri.Scheme}://{x.RequestUri.Host}";

                if(x.RequestUri.Port != 80 && x.RequestUri.Port != 443)
                {
                    downstreamUrl = $"{downstreamUrl}:{x.RequestUri.Port}";
                }

                return $"{downstreamUrl}/";
            });
        }
 public HeaderFindAndReplaceCreator(IBaseUrlFinder finder)
 {
     _finder       = finder;
     _placeholders = new Dictionary <string, Func <string> >();
     _placeholders.Add("{BaseUrl}", () => {
         return(_finder.Find());
     });
 }
Example #3
0
 public RaftController(INode node, IOcelotLoggerFactory loggerFactory, IBaseUrlFinder finder)
 {
     _jsonSerialiserSettings = new JsonSerializerSettings {
         TypeNameHandling = TypeNameHandling.All
     };
     _baseSchemeUrlAndPort = finder.Find();
     _logger = loggerFactory.CreateLogger <RaftController>();
     _node   = node;
 }
Example #4
0
 public HttpPeer(string hostAndPort, HttpClient httpClient, IBaseUrlFinder finder, IInternalConfiguration config, IIdentityServerConfiguration identityServerConfiguration)
 {
     _identityServerConfiguration = identityServerConfiguration;
     _config                 = config;
     Id                      = hostAndPort;
     _hostAndPort            = hostAndPort;
     _httpClient             = httpClient;
     _jsonSerializerSettings = new JsonSerializerSettings()
     {
         TypeNameHandling = TypeNameHandling.All
     };
     _baseSchemeUrlAndPort = finder.Find();
 }
Example #5
0
 private Func <Response <string> > GetBaseUrl()
 {
     return(() => new OkResponse <string>(_finder.Find()));
 }