feat(api): added health check endpoint#11
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a health check endpoint to verify the database connection status. The endpoint returns HTTP 200 if the database is reachable and HTTP 503 if it is not.
Changes:
- Added a new
/healthendpoint that pings the database - Created a HealthController in the
internal/healthpackage to handle health checks - Integrated the health check endpoint into the router setup
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| main.go | Added setupHealthCheckEndpoint function and integrated it into the router |
| internal/health/controller.go | Created HealthController struct with DB client |
| internal/health/get.go | Implemented Get handler that pings the database and returns appropriate status |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return r | ||
| } | ||
|
|
||
| func setupHealthCheckEndpoint(db *mongo.Client, router *gin.Engine) { |
There was a problem hiding this comment.
The GET handler registration is incomplete. The second argument (handler function) is missing. This should instantiate a HealthController and pass its Get method as the handler.
|
|
||
| func setupHealthCheckEndpoint(db *mongo.Client, router *gin.Engine) { | ||
| hc := &health.HealthController{ |
There was a problem hiding this comment.
The setupHealthCheckEndpoint function should accept the database client as a parameter (similar to setupEndpoints) to pass it to the HealthController, since the health check needs to ping the database.
Closes #8