Skip to main content

GET /api/health

Returns the health status of the DefDrive API server. This endpoint is useful for monitoring, load balancer health checks, and verifying that the server is running.

Authentication

This endpoint does not require authentication.

Response

status
string
Always returns "ok" when the server is operational

Example request

curl http://localhost:8080/api/health

Example response

{
  "status": "ok"
}

Use cases

Load balancer checks

Configure your load balancer to ping this endpoint to verify server health

Monitoring systems

Set up monitoring tools to poll this endpoint and alert on failures

Container orchestration

Use as a liveness/readiness probe in Kubernetes or Docker Swarm

CI/CD validation

Verify deployment success by checking health after deployment

Docker health check

This endpoint is used in Docker Compose health checks:
docker-compose.yml
services:
  app:
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/api/health"]
      interval: 30s
      timeout: 10s
      retries: 3

Kubernetes probe

Use this endpoint for Kubernetes liveness and readiness probes:
deployment.yaml
livenessProbe:
  httpGet:
    path: /api/health
    port: 8080
  initialDelaySeconds: 10
  periodSeconds: 30

readinessProbe:
  httpGet:
    path: /api/health
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 10

Implementation

This endpoint is implemented in routes/routes.go:69-72 as a simple anonymous function that returns a JSON response with status: "ok".
The health check only verifies that the HTTP server is responding. It does not check database connectivity or other service dependencies. Consider implementing a more comprehensive health check endpoint for production monitoring.

Build docs developers (and LLMs) love