Skip to content

Add Backend Health Check Endpoint#110

Merged
tgrunnagle merged 2 commits into
mainfrom
issue_108_health_check_2026-01-25
Jan 25, 2026
Merged

Add Backend Health Check Endpoint#110
tgrunnagle merged 2 commits into
mainfrom
issue_108_health_check_2026-01-25

Conversation

@tgrunnagle
Copy link
Copy Markdown
Owner

Summary

This PR implements a standard health check endpoint at /health for the go-towerfall backend server, enabling better monitoring, orchestration, and operational visibility.

Closes: #108

Changes

New Endpoint: GET /health

Added a new health check endpoint that returns a simple JSON response indicating server health status:

{
  "status": "ok",
  "timestamp": "2026-01-25T20:22:28Z"
}

Implementation Details

  1. Response Type (http_types.go:75-79)

    • Added HealthCheckResponse struct with status and timestamp fields
  2. Request Handler (http_handlers.go:999-1028)

    • Implemented HandleHealth handler following existing backend patterns
    • Accepts GET requests only (returns 405 for other methods)
    • Supports CORS preflight (OPTIONS requests)
    • Returns 200 OK with JSON response containing status and UTC timestamp
  3. Route Registration (main.go:16)

    • Registered /health route in main server initialization
    • Positioned before other endpoints for clarity

Design Decisions

  • Path Choice: /health (industry standard) instead of /api/health

    • Used by Kubernetes liveness/readiness probes
    • Standard for AWS ELB/ALB, GCP Load Balancers, Azure Load Balancers
    • Separates operational endpoints from business API
  • No Authentication: Health checks are publicly accessible for monitoring tools

  • Simple Response: Returns minimal data (status + timestamp) for fast responses

  • CORS-Enabled: Supports cross-origin requests with proper headers

Testing

Verified the endpoint works correctly:

GET /health returns 200 OK with valid JSON response
OPTIONS /health returns 200 OK with CORS headers (preflight support)
POST /health returns 405 Method Not Allowed with error message
✓ Backend builds successfully without errors

Use Cases

This endpoint enables:

  • Container orchestration health checks (Kubernetes, Docker, ECS)
  • Load balancer health monitoring (AWS, GCP, Azure)
  • CI/CD pipeline health verification
  • Monitoring and alerting systems
  • Development/debugging operational status checks

@tgrunnagle tgrunnagle merged commit 2c3b25c into main Jan 25, 2026
4 of 5 checks passed
@tgrunnagle tgrunnagle deleted the issue_108_health_check_2026-01-25 branch January 25, 2026 23:00
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.

Add backend health check endpoint

1 participant