Remove DisplayName overload from health checks

The builder now provides this directly.
This commit is contained in:
Ryan Nowak 2019-03-12 16:41:45 -07:00
parent 0dc14a61ce
commit 30d0afca05
2 changed files with 6 additions and 40 deletions

View File

@ -16,7 +16,6 @@ namespace Microsoft.AspNetCore.Builder
{
public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder MapHealthChecks(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder routes, string pattern) { throw null; }
public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder MapHealthChecks(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder routes, string pattern, Microsoft.AspNetCore.Diagnostics.HealthChecks.HealthCheckOptions options) { throw null; }
public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder MapHealthChecks(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder routes, string pattern, Microsoft.AspNetCore.Diagnostics.HealthChecks.HealthCheckOptions options, string displayName) { throw null; }
}
}
namespace Microsoft.AspNetCore.Diagnostics.HealthChecks

View File

@ -2,12 +2,11 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Builder
{
@ -33,7 +32,7 @@ namespace Microsoft.AspNetCore.Builder
throw new ArgumentNullException(nameof(routes));
}
return MapHealthChecksCore(routes, pattern, null, DefaultDisplayName);
return MapHealthChecksCore(routes, pattern, null);
}
/// <summary>
@ -58,42 +57,10 @@ namespace Microsoft.AspNetCore.Builder
throw new ArgumentNullException(nameof(options));
}
return MapHealthChecksCore(routes, pattern, options, DefaultDisplayName);
return MapHealthChecksCore(routes, pattern, options);
}
/// <summary>
/// Adds a health checks endpoint to the <see cref="IEndpointRouteBuilder"/> with the specified template, options and display name.
/// </summary>
/// <param name="routes">The <see cref="IEndpointRouteBuilder"/> to add the health checks endpoint to.</param>
/// <param name="pattern">The URL pattern of the health checks endpoint.</param>
/// <param name="options">A <see cref="HealthCheckOptions"/> used to configure the health checks.</param>
/// <param name="displayName">The display name for the endpoint.</param>
/// <returns>A convention routes for the health checks endpoint.</returns>
public static IEndpointConventionBuilder MapHealthChecks(
this IEndpointRouteBuilder routes,
string pattern,
HealthCheckOptions options,
string displayName)
{
if (routes == null)
{
throw new ArgumentNullException(nameof(routes));
}
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
if (string.IsNullOrEmpty(displayName))
{
throw new ArgumentException("A valid non-empty display name must be provided.", nameof(displayName));
}
return MapHealthChecksCore(routes, pattern, options, displayName);
}
private static IEndpointConventionBuilder MapHealthChecksCore(IEndpointRouteBuilder routes, string pattern, HealthCheckOptions options, string displayName)
private static IEndpointConventionBuilder MapHealthChecksCore(IEndpointRouteBuilder routes, string pattern, HealthCheckOptions options)
{
if (routes.ServiceProvider.GetService(typeof(HealthCheckService)) == null)
{
@ -109,7 +76,7 @@ namespace Microsoft.AspNetCore.Builder
.UseMiddleware<HealthCheckMiddleware>(args)
.Build();
return routes.Map(pattern, displayName, pipeline);
return routes.Map(pattern, pipeline).WithDisplayName(DefaultDisplayName);
}
}
}