webhook

package
v0.0.0-...-c98162d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package webhook implements the HTTP handler that receives Gitea webhook events (commit_status) and routes them to the check monitor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeSignature

func ComputeSignature(body []byte, secret string) string

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 Handler

func Handler(secret string, repos RepoLookup, queueSvc *queue.Service) http.Handler

Handler returns an http.Handler that processes Gitea webhook events.

func ValidateSignature

func ValidateSignature(body []byte, signature, secret string) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL