Пример #1
0
 public ApiEndpoint(ApiEndpointConfiguration configuration, IApiVersionProvider apiVersionProvider)
 {
     _apiVersionProvider = apiVersionProvider;
     Configuration       = configuration;
     _clientHandler      = new HttpClientHandler();
     _client             = new HttpClient(_clientHandler);
 }
Пример #2
0
 public VersionController(
     IDomainModelProvider domainModelProvider,
     IApiVersionProvider apiVersionProvider,
     ISystemDateProvider systemDateProvider,
     ApiSettings apiSettings)
 {
     _domainModelProvider = Preconditions.ThrowIfNull(domainModelProvider, nameof(domainModelProvider));
     _apiVersionProvider  = Preconditions.ThrowIfNull(apiVersionProvider, nameof(apiVersionProvider));
     _systemDateProvider  = Preconditions.ThrowIfNull(systemDateProvider, nameof(systemDateProvider));
     _apiSettings         = Preconditions.ThrowIfNull(apiSettings, nameof(apiSettings));
 }
Пример #3
0
        public VersionController(
            IApiConfigurationProvider apiConfigurationProvider,
            IDomainModelProvider domainModelProvider,
            IApiVersionProvider apiVersionProvider)
        {
            Preconditions.ThrowIfNull(apiConfigurationProvider, nameof(apiConfigurationProvider));
            Preconditions.ThrowIfNull(domainModelProvider, nameof(domainModelProvider));
            Preconditions.ThrowIfNull(apiVersionProvider, nameof(apiVersionProvider));

            _apiConfigurationProvider = apiConfigurationProvider;
            _domainModelProvider      = domainModelProvider;
            _apiVersionProvider       = apiVersionProvider;
        }
        public Uri FromPath(string path, ApiEndpointConfiguration endpointConfiguration, IApiVersionProvider apiVersionProvider)
        {
            var apiVersion = apiVersionProvider.GetVersion();

            var apiVersionPath = string.IsNullOrWhiteSpace(apiVersion)
                ? ""
                : $"/v{apiVersion}";

            path = path[0] == '/' ? path : $"/{path}";

            var separatedPath    = path.Split(new[] { '?' }, StringSplitOptions.RemoveEmptyEntries);
            var pathWithoutQuery = separatedPath[0];
            var query            = separatedPath.Length == 2
                ? separatedPath[1]
                : "";

            var uriBuilder = new UriBuilder(_authConfig.SiteUrl)
            {
                Scheme = _authConfig.UseHttps ? "https" : "http",
                Path   = $"{apiVersionPath}{pathWithoutQuery}",
                Query  = query
            };

            uriBuilder.Host = $"{endpointConfiguration.EndpointAlias}.{uriBuilder.Host}";

            return(uriBuilder.Uri);
        }
Пример #5
0
        public Uri FromPath(string path, ApiEndpointConfiguration endpointConfiguration, IApiVersionProvider apiVersionProvider)
        {
            if (string.IsNullOrWhiteSpace(endpointConfiguration.EndpointAddress))
            {
                throw new ArgumentNullException(endpointConfiguration.EndpointAddress);
            }

            var currentPath = new Uri(endpointConfiguration.EndpointAddress).PathAndQuery ?? "";

            var newPath = $"{currentPath}/{path}";

            return(new Uri(new Uri(endpointConfiguration.EndpointAddress), newPath));
        }
Пример #6
0
 public ApiEndpointFactory(IApiVersionProvider apiVersionProvider)
 {
     _apiVersionProvider = apiVersionProvider;
 }