Skip to content

feat: add health check endpoint and Docker HEALTHCHECK#1

Merged
strayer merged 3 commits into
mainfrom
feat/healthcheck
May 25, 2026
Merged

feat: add health check endpoint and Docker HEALTHCHECK#1
strayer merged 3 commits into
mainfrom
feat/healthcheck

Conversation

@strayer
Copy link
Copy Markdown
Owner

@strayer strayer commented May 25, 2026

Summary

  • Add GET /healthz endpoint that returns 200 OK without authentication or IP checks, for container orchestrators
  • Add healthcheck subcommand to the binary, used as the Dockerfile HEALTHCHECK (scratch image has no shell/curl)
  • Healthcheck subcommand respects LISTEN_ADDR to derive the correct port

Test plan

  • Unit tests: healthz returns 200, skips IP auth, rejects non-GET methods
  • go test ./... -cover passes (97.6% coverage on internal/proxy)
  • go vet ./... clean
  • Docker image built and verified container reaches healthy status

Add GET /healthz endpoint that returns 200 OK without authentication
or IP checks, intended for container orchestrators. Add a "healthcheck"
subcommand to the binary that probes /healthz, used as the Dockerfile
HEALTHCHECK since the scratch image has no shell or curl. The
subcommand respects LISTEN_ADDR to derive the correct port.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a lightweight readiness endpoint and container-level health probing so orchestrators can verify the proxy is up without needing auth/IP allowlisting.

Changes:

  • Add unauthenticated GET /healthz endpoint returning 200 OK and rejecting non-GET methods.
  • Add healthcheck subcommand used by Docker HEALTHCHECK to probe /healthz from a scratch-based image.
  • Update tests and implementation plan to cover/mark the new health endpoint behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/proxy/handler.go Registers new /healthz route on the main mux.
internal/proxy/handler_test.go Adds unit tests validating /healthz behavior and auth bypass.
IMPLEMENTATION_PLAN.md Marks health endpoint + Docker healthcheck tasks as complete.
Dockerfile Adds Docker HEALTHCHECK invoking /proxy healthcheck.
cmd/proxy/main.go Implements healthcheck subcommand and dispatch logic in main().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/proxy/main.go
Comment thread cmd/proxy/main.go
Add 2s HTTP client timeout to the healthcheck subcommand instead of
relying solely on Docker's HEALTHCHECK timeout. Add tests covering
success, unreachable server, non-200 response, custom LISTEN_ADDR,
and invalid address parsing.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread cmd/proxy/main.go
Comment thread cmd/proxy/main_test.go
Prevents flaky test by ensuring the server is accepting connections
before the healthcheck probe runs.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread cmd/proxy/main.go
@strayer strayer merged commit ad80f9f into main May 25, 2026
9 checks passed
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.

2 participants