11using ArnabDeveloper . HttpHealthCheck ;
22using ArnabDeveloper . HttpHealthCheck . DI ;
3- using HealthChecks . UI . Client ;
43using HttpHealthCheckDashboard . HealthChecks ;
54using Microsoft . AspNetCore . Builder ;
6- using Microsoft . AspNetCore . Diagnostics . HealthChecks ;
75using Microsoft . AspNetCore . Hosting ;
86using Microsoft . AspNetCore . Http ;
97using Microsoft . Extensions . Configuration ;
@@ -50,11 +48,7 @@ public void ConfigureServices(IServiceCollection services)
5048 }
5149 return urlDetails . AsEnumerable ( ) ;
5250 } )
53- . AddHealthChecks ( )
54- . AddCheck < MicrosoftHealthCheck > ( "Microsoft" )
55- . AddCheck < GoogleHealthCheck > ( "Google" )
56- . AddCheck < InactiveUrlHealthCheck > ( "InactiveUrl" )
57- . AddCheck < InvalidUrlHealthCheck > ( "InvalidUrl" ) ;
51+ . AddHealthChecksUrls ( ) ;
5852
5953 services
6054 . AddHealthChecksUI ( )
@@ -75,26 +69,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
7569
7670 app . UseEndpoints ( endpoints =>
7771 {
78- endpoints . MapHealthChecks ( "/microsoft-hc" , new HealthCheckOptions ( )
79- {
80- Predicate = r => r . Name . Contains ( "Microsoft" ) ,
81- ResponseWriter = UIResponseWriter . WriteHealthCheckUIResponse
82- } ) ;
83- endpoints . MapHealthChecks ( "/google-hc" , new HealthCheckOptions ( )
84- {
85- Predicate = r => r . Name . Contains ( "Google" ) ,
86- ResponseWriter = UIResponseWriter . WriteHealthCheckUIResponse
87- } ) ;
88- endpoints . MapHealthChecks ( "/inactiveurl-hc" , new HealthCheckOptions ( )
89- {
90- Predicate = r => r . Name . Contains ( "InactiveUrl" ) ,
91- ResponseWriter = UIResponseWriter . WriteHealthCheckUIResponse
92- } ) ;
93- endpoints . MapHealthChecks ( "/invalidurl-hc" , new HealthCheckOptions ( )
94- {
95- Predicate = r => r . Name . Contains ( "InvalidUrl" ) ,
96- ResponseWriter = UIResponseWriter . WriteHealthCheckUIResponse
97- } ) ;
72+ endpoints . MapHealthChecksUrls ( ) ;
9873 endpoints . MapGet ( "/" , async context =>
9974 {
10075 await context . Response . WriteAsync ( "Hello World!" ) ;
0 commit comments