Documentation
¶
Overview ¶
Package webhook implements the HTTP handler that receives Gitea webhook events (commit_status) and routes them to the check monitor.
Index ¶
- func ComputeSignature(body []byte, secret string) string
- func GithubHandler(secret []byte, repos RepoLookup, queueSvc *queue.Service, ...) http.Handler
- func Handler(secret string, repos RepoLookup, queueSvc *queue.Service) http.Handler
- func ValidateSignature(body []byte, signature, secret string) bool
- type MapRepoLookup
- type RepoLookup
- type RepoMonitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeSignature ¶
ComputeSignature computes the HMAC-SHA256 hex digest for a request body.
func GithubHandler ¶
func GithubHandler(secret []byte, repos RepoLookup, queueSvc *queue.Service, triggerDiscovery func()) http.Handler
GithubHandler validates X-Hub-Signature-256, dispatches by X-GitHub-Event, and returns 200 for anything it does not act on so GitHub does not mark the delivery as failed.
func ValidateSignature ¶
ValidateSignature checks the HMAC-SHA256 signature from X-Gitea-Signature against the request body using the shared secret.
Types ¶
type MapRepoLookup ¶
type MapRepoLookup map[string]*RepoMonitor
MapRepoLookup adapts a static map to the RepoLookup interface.
func (MapRepoLookup) LookupMonitor ¶
func (m MapRepoLookup) LookupMonitor(fullName string) (*RepoMonitor, bool)
LookupMonitor returns the RepoMonitor for a given "owner/name" key.
type RepoLookup ¶
type RepoLookup interface {
LookupMonitor(fullName string) (*RepoMonitor, bool)
}
RepoLookup abstracts how the webhook handler finds a repo's monitor. Implementations include the RepoRegistry (dynamic) and simple maps (tests).
type RepoMonitor ¶
type RepoMonitor struct {
Deps *monitor.Deps
// TriggerPoll fires an immediate reconcile of the repo's poller. Used
// for PR-level webhooks (auto-merge toggle, close, push) where the
// poller already owns the correct enqueue/dequeue logic.
TriggerPoll func()
}
RepoMonitor holds the per-repo deps webhook handlers need to route events.