Skip to content

Commit 30d0afc

Browse files
committed
Remove DisplayName overload from health checks
The builder now provides this directly.
1 parent 0dc14a6 commit 30d0afc

File tree

2 files changed

+6
-40
lines changed

2 files changed

+6
-40
lines changed

src/Middleware/HealthChecks/ref/Microsoft.AspNetCore.Diagnostics.HealthChecks.netcoreapp3.0.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public static partial class HealthCheckEndpointRouteBuilderExtensions
1616
{
1717
public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder MapHealthChecks(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder routes, string pattern) { throw null; }
1818
public static Microsoft.AspNetCore.Builder.IEndpointConventionBuilder MapHealthChecks(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder routes, string pattern, Microsoft.AspNetCore.Diagnostics.HealthChecks.HealthCheckOptions options) { throw null; }
19-
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; }
2019
}
2120
}
2221
namespace Microsoft.AspNetCore.Diagnostics.HealthChecks

src/Middleware/HealthChecks/src/Builder/HealthCheckEndpointRouteBuilderExtensions.cs

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5-
using Microsoft.AspNetCore.Builder;
65
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
7-
using Microsoft.Extensions.Options;
86
using Microsoft.AspNetCore.Routing;
9-
using Microsoft.Extensions.Diagnostics.HealthChecks;
107
using Microsoft.Extensions.DependencyInjection;
8+
using Microsoft.Extensions.Diagnostics.HealthChecks;
9+
using Microsoft.Extensions.Options;
1110

1211
namespace Microsoft.AspNetCore.Builder
1312
{
@@ -33,7 +32,7 @@ public static IEndpointConventionBuilder MapHealthChecks(
3332
throw new ArgumentNullException(nameof(routes));
3433
}
3534

36-
return MapHealthChecksCore(routes, pattern, null, DefaultDisplayName);
35+
return MapHealthChecksCore(routes, pattern, null);
3736
}
3837

3938
/// <summary>
@@ -58,42 +57,10 @@ public static IEndpointConventionBuilder MapHealthChecks(
5857
throw new ArgumentNullException(nameof(options));
5958
}
6059

61-
return MapHealthChecksCore(routes, pattern, options, DefaultDisplayName);
62-
}
63-
64-
/// <summary>
65-
/// Adds a health checks endpoint to the <see cref="IEndpointRouteBuilder"/> with the specified template, options and display name.
66-
/// </summary>
67-
/// <param name="routes">The <see cref="IEndpointRouteBuilder"/> to add the health checks endpoint to.</param>
68-
/// <param name="pattern">The URL pattern of the health checks endpoint.</param>
69-
/// <param name="options">A <see cref="HealthCheckOptions"/> used to configure the health checks.</param>
70-
/// <param name="displayName">The display name for the endpoint.</param>
71-
/// <returns>A convention routes for the health checks endpoint.</returns>
72-
public static IEndpointConventionBuilder MapHealthChecks(
73-
this IEndpointRouteBuilder routes,
74-
string pattern,
75-
HealthCheckOptions options,
76-
string displayName)
77-
{
78-
if (routes == null)
79-
{
80-
throw new ArgumentNullException(nameof(routes));
81-
}
82-
83-
if (options == null)
84-
{
85-
throw new ArgumentNullException(nameof(options));
86-
}
87-
88-
if (string.IsNullOrEmpty(displayName))
89-
{
90-
throw new ArgumentException("A valid non-empty display name must be provided.", nameof(displayName));
91-
}
92-
93-
return MapHealthChecksCore(routes, pattern, options, displayName);
60+
return MapHealthChecksCore(routes, pattern, options);
9461
}
9562

96-
private static IEndpointConventionBuilder MapHealthChecksCore(IEndpointRouteBuilder routes, string pattern, HealthCheckOptions options, string displayName)
63+
private static IEndpointConventionBuilder MapHealthChecksCore(IEndpointRouteBuilder routes, string pattern, HealthCheckOptions options)
9764
{
9865
if (routes.ServiceProvider.GetService(typeof(HealthCheckService)) == null)
9966
{
@@ -109,7 +76,7 @@ private static IEndpointConventionBuilder MapHealthChecksCore(IEndpointRouteBuil
10976
.UseMiddleware<HealthCheckMiddleware>(args)
11077
.Build();
11178

112-
return routes.Map(pattern, displayName, pipeline);
79+
return routes.Map(pattern, pipeline).WithDisplayName(DefaultDisplayName);
11380
}
11481
}
11582
}

0 commit comments

Comments
 (0)