{"modulePath":"github.com/bborbe/github-pr-watcher","version":"v0.31.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package handler\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 SinglePRTriggerHandler = libhttp.WithError\n```\nSinglePRTriggerHandler handles POST /trigger?url=\\\u003cpr\\_url\u003e. The handler is intentionally thin: parse the URL, validate it synchronously, publish a TriggerPRReviewCommand to Kafka, and return HTTP 202. All GitHub API access, filter evaluation, and trust decision logic is owned by the in-pod command consumer.\n\n```go\nfunc NewSinglePRTriggerHandler(\n\tsender command.TriggerPRReviewCommandSender,\n) SinglePRTriggerHandler\n```\nNewSinglePRTriggerHandler returns a handler that publishes a TriggerPRReviewCommand to Kafka for each valid /trigger request.\n\n```go\ntype WebhookHandler = libhttp.WithError\n```\nWebhookHandler handles POST /webhook/github-pr. The handler is intentionally thin, mirroring SinglePRTriggerHandler: verify the GitHub HMAC signature, extract the PR URL from the pull\\_request event, publish a TriggerPRReviewCommand to Kafka, and return 202. All GitHub API access, filter evaluation, and trust logic stays in the in-pod command consumer (shared with /trigger), so gates 1–4 and the (repo, sha) task-ID dedup apply to webhook deliveries unchanged.\n\n```go\nfunc NewWebhookHandler(\n\tsender command.TriggerPRReviewCommandSender,\n\tstatusSender command.SetDoNotMergeStatusCommandSender,\n\treviewSender command.SetDoNotMergeReviewCommandSender,\n\ttaskLinkSender command.SetTaskLinkStatusCommandSender,\n\tcoalescer coalesce.Coalescer,\n\tsecret string,\n\tmetrics WebhookMetrics,\n\tclock libtime.CurrentDateTimeGetter,\n) WebhookHandler\n```\nNewWebhookHandler returns a handler that publishes a TriggerPRReviewCommand for each signature-verified pull\\_request webhook delivery, unless the coalescer holds the push for its trailing dispatch, and the do-not-merge gate's commands on every delivery that can change the label state, plus the task-link status on every delivery that can change the PR body.\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}\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-pr-watcher/pkg/handler","name":"handler","synopsis":"","isRedistributable":true}
