Skip to content

Embedded HTTP server with health endpoint #26

Description

@sunba91-su

Goal

Add a lightweight embedded HTTP server to the Go bot for health checks and future WebUI.

Acceptance Criteria

  • Create internal/web/ package
  • Start HTTP server alongside the Rocket.Chat client (in a goroutine)
  • GET /health returns 200 with JSON body:
    {
      "status": "ok",
      "database": "connected",
      "rocketchat": "connected",
      "uptime": "1h23m45s"
    }
  • Configurable via env vars:
    • WEBUI_ENABLED (default: true)
    • WEBUI_PORT (default: 8080)
  • Graceful shutdown on SIGINT/SIGTERM
  • Log when server starts/stops
  • Server exits silently if WEBUI_ENABLED=false
  • Update .env.example with new vars
  • Update README env table

Technical Notes

  • Use standard library net/http (no external router dependency)
  • Use http.Server with ReadHeaderTimeout, WriteTimeout for basic hardening
  • DB health: run a simple SELECT 1 via the store
  • Rocket.Chat health: check if client is connected (add a IsConnected() bool method to Client if needed)
  • Uptime: start a time.Time in main, pass to web handler via closure
  • The /health endpoint should NOT require auth (it is for Docker HEALTHCHECK/load balancers)

Dependencies

  • None (can be built independently)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions