webhook

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package webhook owns the optional HTTP surface for health, metrics and provider webhooks.

Index

Constants

View Source
const (
	DefaultMaxBodyBytes = 64 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ListenAddr        string
	MetricsEnabled    bool
	TributeEnabled    bool
	TelegramEnabled   bool
	TributePath       string
	TelegramPath      string
	MaxBodyBytes      int64
	ReadHeaderTimeout time.Duration
	ReadTimeout       time.Duration
	ShutdownTimeout   time.Duration
	Readiness         Readiness
	Metrics           *Metrics
	Tribute           http.Handler
	Telegram          http.Handler
	Logger            *slog.Logger
}

Config controls the optional HTTP server.

type Metrics

type Metrics struct {
	Ops *store.Ops
}

Metrics writes a small Prometheus text exposition from durable state.

func (*Metrics) Write

func (m *Metrics) Write(ctx context.Context, w io.Writer) error

Write emits metrics with bounded labels only.

type Readiness

type Readiness struct {
	DB                                 *sql.DB
	HealthKeys                         []string
	ReconcileInterval                  time.Duration
	GetMeOK                            func() bool
	RequireTelegramWebhookRegistration bool
	TelegramWebhookRegistered          func() bool
	Now                                func() time.Time
}

Readiness contains dependencies used by /readyz.

func (Readiness) Check

Check returns readiness failures without performing external network calls.

type ReadinessResult

type ReadinessResult struct {
	Ready  bool
	Failed []string
}

ReadinessResult is the machine-readable readiness decision.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is an optional HTTP runtime.

func NewServer

func NewServer(cfg Config) *Server

NewServer builds an HTTP server with only enabled routes mounted.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler exposes the route-gated mux for tests.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run serves until ctx is cancelled, then performs graceful shutdown.

type TelegramHandler

type TelegramHandler struct {
	Secret    string
	Processor TelegramProcessor
}

TelegramHandler accepts Telegram webhook updates.

func NewTelegramHandler

func NewTelegramHandler(secret string, processor TelegramProcessor) *TelegramHandler

NewTelegramHandler returns a Telegram webhook handler.

func (*TelegramHandler) ServeHTTP

func (h *TelegramHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP verifies Telegram's secret token before reading the update.

type TelegramProcessor

type TelegramProcessor interface {
	HandleWebhookUpdate(ctx context.Context, raw []byte) error
}

TelegramProcessor is the durable Telegram webhook processing surface.

type TributeHandler

type TributeHandler struct {
	DB              *sql.DB
	APIKey          string
	Engine          *engine.Engine
	CancelImmediate bool
	OwnerIDs        []int64
	AdminLogChatID  *int64
	OperatorLog     *operatorlog.Writer
	Logger          *slog.Logger
}

TributeHandler accepts Tribute webhooks.

func (*TributeHandler) ServeHTTP

func (h *TributeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP validates and processes one Tribute webhook.

Jump to

Keyboard shortcuts

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