Help us shape the future of Go! Take the 2026 Go Developer Survey

webhook

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package webhook delivers Console events to an arbitrary HTTP endpoint as a JSON POST. It is the generic sink: any service that can accept a JSON webhook (a custom handler, an automation platform, a serverless function) can consume Console events without a bespoke integration.

When a Secret is configured it is sent verbatim in the X-Webhook-Secret request header, letting the receiver authenticate the caller with a simple shared-secret check.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notifier

type Notifier struct {
	// URL is the endpoint the event is POSTed to.
	URL string
	// Secret, when set, is sent in the X-Webhook-Secret header so the receiver
	// can authenticate the caller.
	Secret string
	// HTTP issues the POST. If nil, a client with a sane timeout is used.
	HTTP *http.Client
}

Notifier posts events to a configured HTTP endpoint as JSON.

func New

func New(url string, opts ...Option) *Notifier

New builds a webhook notifier for the given endpoint URL.

func (*Notifier) Name

func (n *Notifier) Name() string

Name identifies the sink.

func (*Notifier) Notify

func (n *Notifier) Notify(ctx context.Context, ev core.Event) error

Notify POSTs ev to the configured URL as a JSON object. The event's own JSON fields are emitted, plus a top-level "severity" derived from the event type.

type Option

type Option func(*Notifier)

Option configures a Notifier.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets the HTTP client.

func WithSecret

func WithSecret(s string) Option

WithSecret sets the shared secret sent in the X-Webhook-Secret header.

Jump to

Keyboard shortcuts

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