2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
4
using System ;
5
- using Microsoft . AspNetCore . Builder ;
6
5
using Microsoft . AspNetCore . Diagnostics . HealthChecks ;
7
- using Microsoft . Extensions . Options ;
8
6
using Microsoft . AspNetCore . Routing ;
9
- using Microsoft . Extensions . Diagnostics . HealthChecks ;
10
7
using Microsoft . Extensions . DependencyInjection ;
8
+ using Microsoft . Extensions . Diagnostics . HealthChecks ;
9
+ using Microsoft . Extensions . Options ;
11
10
12
11
namespace Microsoft . AspNetCore . Builder
13
12
{
@@ -33,7 +32,7 @@ public static IEndpointConventionBuilder MapHealthChecks(
33
32
throw new ArgumentNullException ( nameof ( routes ) ) ;
34
33
}
35
34
36
- return MapHealthChecksCore ( routes , pattern , null , DefaultDisplayName ) ;
35
+ return MapHealthChecksCore ( routes , pattern , null ) ;
37
36
}
38
37
39
38
/// <summary>
@@ -58,42 +57,10 @@ public static IEndpointConventionBuilder MapHealthChecks(
58
57
throw new ArgumentNullException ( nameof ( options ) ) ;
59
58
}
60
59
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 ) ;
94
61
}
95
62
96
- private static IEndpointConventionBuilder MapHealthChecksCore ( IEndpointRouteBuilder routes , string pattern , HealthCheckOptions options , string displayName )
63
+ private static IEndpointConventionBuilder MapHealthChecksCore ( IEndpointRouteBuilder routes , string pattern , HealthCheckOptions options )
97
64
{
98
65
if ( routes . ServiceProvider . GetService ( typeof ( HealthCheckService ) ) == null )
99
66
{
@@ -109,7 +76,7 @@ private static IEndpointConventionBuilder MapHealthChecksCore(IEndpointRouteBuil
109
76
. UseMiddleware < HealthCheckMiddleware > ( args )
110
77
. Build ( ) ;
111
78
112
- return routes . Map ( pattern , displayName , pipeline ) ;
79
+ return routes . Map ( pattern , pipeline ) . WithDisplayName ( DefaultDisplayName ) ;
113
80
}
114
81
}
115
82
}
0 commit comments