webhook

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 17 Imported by: 0

README

Webhook Plugin

The webhook plugin sends an HTTP request when the endpoint status changes.

Plugin config

{
  "url": "https://example.com/link-events",
  "resource_id": "resource-123",
  "secret": "shared-secret",
  "headers": {
    "Authorization": "Bearer my-token",
    "X-Custom": "custom-value"
  }
}
  • url is required and must use http or https.
  • resource_id is required and identifies the external resource tied to the webhook. Link derives the election key from resource_id, so endpoints configured with the same resource_id compete for the same activation lock. Only one Link instance will activate the endpoint for a given resource_id.
  • secret is required, stored encrypted, and used to sign webhook requests.
  • headers is optional and contains extra headers injected in the request.

Request payload

The plugin sends a POST request to url with a JSON body:

{
  "endpoint_id": "vip-...",
  "resource_id": "resource-123",
  "plugin": "webhook",
  "status": "ACTIVATED"
}

Requests include these Link headers:

  • X-Link-Webhook-Resource-ID: the resource_id from the plugin config. Consumers can use it to derive the webhook key before reading the request body.
  • X-Link-Webhook-Timestamp: Unix timestamp in seconds.
  • X-Link-Webhook-Signature: hex-encoded HMAC-SHA256 of "<timestamp>.<body>".

Documentation

Index

Constants

Variables

This section is empty.

Functions

func Register

func Register(ctx context.Context, registry plugin.Registry, encryptedStorage models.EncryptedStorage) error

Types

type Config

type Config struct {
	RefreshEvery time.Duration `envconfig:"WEBHOOK_REFRESH_INTERVAL" default:"5m"`
}

type Factory

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

func (Factory) Create

func (f Factory) Create(ctx context.Context, endpoint models.Endpoint) (plugin.Plugin, error)

func (Factory) Mutate

func (f Factory) Mutate(ctx context.Context, endpoint models.Endpoint) (json.RawMessage, error)

func (Factory) Validate

func (f Factory) Validate(_ context.Context, endpoint models.Endpoint) error

type Plugin

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

func (*Plugin) Activate

func (p *Plugin) Activate(ctx context.Context) error

func (*Plugin) Deactivate

func (p *Plugin) Deactivate(ctx context.Context) error

func (*Plugin) ElectionKey

func (p *Plugin) ElectionKey(_ context.Context) string

func (*Plugin) Ensure

func (p *Plugin) Ensure(ctx context.Context) error

type PluginConfig

type PluginConfig = api.WebhookPluginConfig

type StorablePluginConfig

type StorablePluginConfig struct {
	URL        string                              `json:"url"`
	Headers    map[string]models.EncryptedDataLink `json:"headers,omitempty"`
	Secret     models.EncryptedDataLink            `json:"secret"`
	ResourceID string                              `json:"resource_id"`
}

Jump to

Keyboard shortcuts

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