@@ -54,6 +54,38 @@ await healthCheck.StartAsync();
5454``` csharp
5555// Start both SMTP and health check together
5656var healthCheck = await server .StartWithHealthCheckAsync (8080 );
57+
58+ // Or with custom health checks configured inline
59+ await server .StartWithHealthCheckAsync (8080 , healthService =>
60+ {
61+ // Add custom health checks
62+ healthService .AddHealthCheck (" database" , async (ct ) =>
63+ {
64+ try
65+ {
66+ await CheckDatabaseAsync ();
67+ return HealthCheckResult .Healthy (" Database connected" );
68+ }
69+ catch (Exception ex )
70+ {
71+ return HealthCheckResult .Unhealthy (" Database unavailable" , ex );
72+ }
73+ });
74+
75+ healthService .AddHealthCheck (" redis" , async (ct ) =>
76+ {
77+ try
78+ {
79+ await CheckRedisAsync ();
80+ return HealthCheckResult .Healthy (" Redis connected" );
81+ }
82+ catch (Exception ex )
83+ {
84+ // Redis is not critical, mark as degraded
85+ return HealthCheckResult .Degraded (" Redis unavailable" , ex );
86+ }
87+ });
88+ });
5789```
5890
5991## 🛠️ Advanced Configuration
@@ -383,11 +415,16 @@ curl -f http://localhost:8080/health/readyz
383415| Method | Description |
384416| --------| -------------|
385417| ` EnableHealthCheck(port) ` | Enable health check on localhost |
386- | ` AddHealthCheck(name, checkFunc) ` | Add custom health check |
418+ | ` AddHealthCheck(name, checkFunc) ` | Add custom health check to service |
387419| ` StartWithHealthCheckAsync(port) ` | Start server and health check |
388420| ` EnableHealthCheck(hostname, port) ` | Enable on specific hostname |
389421| ` EnableHealthCheck(IPAddress, port) ` | Enable on specific IP |
390422| ` EnableHealthCheck(options, healthOptions) ` | Advanced configuration |
423+ | ` StartWithHealthCheckAsync(hostname, port) ` | Start on specific hostname |
424+ | ` StartWithHealthCheckAsync(IPAddress, port) ` | Start on specific IP |
425+ | ` StartWithHealthCheckAsync(port, configureHealthChecks) ` | Start server with custom health checks |
426+ | ` StartWithHealthCheckAsync(hostname, port, configureHealthChecks) ` | Start on hostname with custom checks |
427+ | ` StartWithHealthCheckAsync(IPAddress, port, configureHealthChecks) ` | Start on IP with custom checks |
391428
392429### Health Check Results
393430
0 commit comments