コード例 #1
0
 public ApiVersionResponse(
     MarketingVersion version,
     IDictionary <string, string> components)
 {
     Version    = version.ToString();
     Components = components
                  .OrderBy(x => x.Key)
                  .ToDictionary(x => x.Key, x => x.Value);
 }
コード例 #2
0
        public async Task <IActionResult> Get(
            [FromServices] IConfiguration configuration,
            [FromServices] HealthUrls healthUrls,
            [FromServices] MarketingVersion version,
            [FromServices] ILifetimeScope scope,
            CancellationToken cancellationToken = default)
        {
            var components = new ConcurrentDictionary <string, string>();

            components.TryAdd("publicApi", FormatVersion(Assembly.GetEntryAssembly().GetName().Version.ToString(4)));
            components.TryAdd("publicSite", configuration["SiteVersion"]);

            await Task.WhenAll(healthUrls.Select(url => GetDownstreamVersionAsync(url.Key, scope, components, cancellationToken)));

            return(Ok(new ApiVersionResponse(version, components)));
        }