{"modulePath":"github.com/bborbe/github-build-watcher","version":"v0.9.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package handler\n\nPackage handler contains the HTTP handlers for the github-build watcher. /trigger publishes a TriggerBuildCheckCommand to Kafka and returns 202; the heavy lifting (Poll cycle) happens in the in-pod command consumer.\n\n## Variables\n\n```go\nvar AvailableWebhookHeaders = []WebhookHeader{WebhookSignatureHeader, WebhookEventHeader}\n```\nAvailableWebhookHeaders lists the webhook header names the handler reads.\n\n## Types\n\n```go\ntype TriggerBuildCheckHandler = libhttp.WithError\n```\nTriggerBuildCheckHandler handles POST /trigger. The handler is intentionally minimal: parse the optional ?force=\\\u003cbool\u003e query parameter via libparse.ParseBoolDefault (spec 069), build a TriggerBuildCheckCommand carrying the parsed Force value, publish it to Kafka via the injected sender, and return HTTP 202. The Scope field stays reserved-unread (spec Non-goal: per-repo filter UX is a separate spec). All scan-cycle work is owned by the in-pod command consumer.\n\n```go\nfunc NewTriggerBuildCheckHandler(\n\tsender command.TriggerBuildCheckCommandSender,\n) TriggerBuildCheckHandler\n```\nNewTriggerBuildCheckHandler returns a handler that publishes a TriggerBuildCheckCommand to Kafka for each /trigger request and returns 202. The sender is the only collaborator.\n\n```go\ntype WebhookHandler = libhttp.WithError\n```\nWebhookHandler handles POST /webhook/github-build. The handler is intentionally thin, mirroring TriggerBuildCheckHandler: verify the GitHub HMAC signature, extract the repo from the workflow\\_run event, publish a TriggerBuildCheckCommand to Kafka, and return 202. All GitHub API access, filter evaluation, and state-machine logic stays in the in-pod command consumer (shared with /trigger), so the allowlist gate and the green/red state transitions apply to webhook deliveries unchanged.\n\n```go\nfunc NewWebhookHandler(\n\tsender command.TriggerBuildCheckCommandSender,\n\tsecret string,\n\tmetrics WebhookMetrics,\n\tclock libtime.CurrentDateTimeGetter,\n\tdebouncer pkg.Debouncer,\n) WebhookHandler\n```\nNewWebhookHandler returns a handler that publishes a TriggerBuildCheckCommand for each signature-verified workflow\\_run webhook delivery that (a) completed with conclusion=failure, (b) ran on the repository's default branch, and (c) passes the per-repo debounce. All other deliveries are acked and skipped.\n\n```go\ntype WebhookHeader string\n```\nWebhookHeader is a typed GitHub webhook header name, so header-name typos are caught by the type system.\n\n```go\nconst (\n\tWebhookSignatureHeader WebhookHeader = \"X-Hub-Signature-256\"\n\tWebhookEventHeader     WebhookHeader = \"X-GitHub-Event\"\n)\n```\n\n```go\ntype WebhookMetrics interface {\n\tIncWebhookDelivery(result string)\n\tIncWebhookSignatureRejected()\n\tObserveWebhookDispatchLatency(seconds float64)\n\t// IncWebhookSkipped counts workflow_run deliveries that did not dispatch a\n\t// build-check. reason: \"not_completed\" | \"not_failure\" | \"not_default_branch\" | \"debounced\".\n\tIncWebhookSkipped(reason string)\n}\n```\nWebhookMetrics is the narrow slice of watcher metrics the webhook handler records. pkg.Metrics satisfies it structurally, keeping this handler free of the pkg import — mirroring trigger\\_handler's thin dependency set.\n\n","path":"github.com/bborbe/github-build-watcher/pkg/handler","name":"handler","synopsis":"Package handler contains the HTTP handlers for the github-build watcher.","isRedistributable":true}
