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

webhook

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderSignature = "X-Signature-256"
	HeaderTimestamp = "X-RDPanel-Timestamp"
)

Signature headers. With a secret, X-Signature-256 is "sha256=" + hex(HMAC-SHA256(secret, timestamp + "." + body)) where timestamp is the X-RDPanel-Timestamp value (Unix seconds); receivers should reject stale timestamps to stop replays (docs/configuration.md#webhooks).

Variables

This section is empty.

Functions

func SafeURL added in v0.11.0

func SafeURL(raw string) string

SafeURL is the scheme and host of a webhook URL: what may be logged (paths and queries of webhook URLs often embed tokens).

func Sign added in v0.11.0

func Sign(secret string, ts int64, body []byte) string

Sign returns the X-Signature-256 value for body sent at timestamp ts (Unix seconds, the X-RDPanel-Timestamp value).

Types

type Config

type Config struct {
	URL    string
	Secret string
	Bus    *events.Bus
	Log    *slog.Logger
	Client *http.Client
	Now    func() time.Time
}

Config configures the webhook dispatcher.

type Payload

type Payload struct {
	Event     string    `json:"event"`
	Timestamp time.Time `json:"timestamp"`
	Data      any       `json:"data"`
}

Payload is the JSON structure sent to the webhook endpoint.

type Service

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

Service subscribes to critical events and sends HTTP POST notifications.

func New

func New(cfg Config) *Service

New creates a new webhook Service.

func (*Service) Run

func (s *Service) Run(ctx context.Context)

Run listens for critical events on the event bus until ctx is cancelled.

Jump to

Keyboard shortcuts

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