Health Checks
Liveness and readiness endpoints for container orchestration.
RapidGo provides health check endpoints for monitoring and container orchestration (Docker, Kubernetes).
Setup
import "github.com/RAiWorks/RapidGo/v2/core/health"
health.Routes(r, func() *gorm.DB {
return container.MustMake[*gorm.DB](c, "db")
})
Endpoints
GET /health (Liveness)
Returns 200 OK if the application is running:
{"status": "ok"}
GET /health/ready (Readiness)
Checks database connectivity and returns:
Healthy:
{"status": "ready", "db": "connected"}
Unhealthy (503):
{"status": "error", "db": "connection refused"}
Docker Health Check
The starter's Dockerfile includes a built-in health check:
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s \
CMD wget -qO- http://localhost:8080/health || exit 1
Kubernetes Probes
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /health/ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10