Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 20, 2025

Adds a lightweight /healthz endpoint to improve observability and support Kubernetes readiness/liveness probes.

Changes Made

  • New endpoint: Added /healthz route that responds to GET requests
  • Response format: Returns HTTP 200 status with body "OK\n"
  • Logging: Added optional logging for health check requests
  • Testing: Added HTTP integration test to verify status code and response body
  • Build: Updated .gitignore to exclude binary files

Implementation Details

func healthzHandler(w http.ResponseWriter, r *http.Request) {
    log.Printf("Health check request received")
    w.WriteHeader(http.StatusOK)
    w.Write([]byte("OK\n"))
}

The endpoint follows standard health check patterns and requires no query parameters. It's designed for:

  • Kubernetes readiness/liveness probes
  • Load balancer health checks
  • CI tests verifying server availability

Testing

curl -i http://localhost:8080/healthz
# HTTP/1.1 200 OK
# Content-Length: 3
# 
# OK

All existing functionality remains unchanged and tests continue to pass.

Fixes #7.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Title: Add a /healthz endpoint for basic readiness/liveness checks Add /healthz endpoint for basic readiness/liveness checks Jul 20, 2025
@Copilot Copilot AI requested a review from nofarblue July 20, 2025 12:22
Copilot finished work on behalf of nofarblue July 20, 2025 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Title: Add a /healthz endpoint for basic readiness/liveness checks

2 participants