guibranco / guibranco/gstraccini-bot-handler
[FEATURE] Enable health check for ASP.NET REST API
- Dominant language
- Shell
- Stars
- 1
- Forks
- 0
- Avg merge
- 1m
- Merged PRs (30d)
- 2
Description
Add support for the ASP.NET health check feature to the REST API. This will provide an endpoint to monitor the API's health status and enable smoke testing after CI/CD runs.
#### Requirements
- Enable the ASP.NET Health Check feature.
- Expose a health check endpoint (e.g., `/health`).
- Ensure the health check includes basic verifications, such as API availability and necessary dependencies.
- The health check should be lightweight and suitable for automated smoke testing.
#### Example Implementation
Here is an example of how to enable a basic health check in an ASP.NET REST API:
```csharp
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = WebApplication.CreateBuilder(args);
// Add health checks to the service collection
builder.Services.AddHealthChecks();
var app = builder.Build();
// Map the health check endpoint
app.MapHealthChecks("/health");
app.Run();
```
In this example:
- A `/health` endpoint is exposed that checks the primary health status of the application.
- Additional health checks for dependencies (e.g., database, external services) can be added as needed.
#### Acceptance Criteria
- [ ] Health check endpoint is available and accessible.
- [ ] Basic API health status is reported.
- [ ] Health check can be used for automated smoke tests in CI/CD pipelines.
- [ ] Documentation is updated to specify the endpoint and its purpose.
#### Notes
- Consider future extensibility for adding checks for specific dependencies (e.g., database, external APIs).
- Ensure the health check endpoint does not expose sensitive information.
Contributor guide
Assessment
This issue has not been assessed yet.