desthookdeck

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTokenBase64 = errors.New("invalid token: not base64 encoded")
	ErrInvalidTokenFormat = errors.New("invalid token format: expected 'id:random_string'")
	ErrJSONMarshalFailed  = errors.New("failed to marshal event data to JSON")
	ErrTokenVerification  = errors.New("failed to verify token with Hookdeck API")
)

Standard error definitions for token parsing

Functions

func CreateRequest

func CreateRequest(token *HookdeckToken, event *models.Event, metadata map[string]string) (*http.Request, error)

CreateRequest creates an HTTP request for a Hookdeck destination

Types

type HookdeckConfig

type HookdeckConfig struct {
}

Configuration type - empty since we don't have config fields

type HookdeckCredentials

type HookdeckCredentials struct {
	Token string
}

Credentials type

type HookdeckProvider

type HookdeckProvider struct {
	*destregistry.BaseProvider
	// contains filtered or unexported fields
}

Provider implementation

func New

Constructor

func (*HookdeckProvider) ComputeTarget

func (p *HookdeckProvider) ComputeTarget(destination *models.Destination) destregistry.DestinationTarget

ComputeTarget returns a human-readable target

func (*HookdeckProvider) CreatePublisher

func (p *HookdeckProvider) CreatePublisher(ctx context.Context, destination *models.Destination) (destregistry.Publisher, error)

CreatePublisher creates a new publisher instance

func (*HookdeckProvider) Preprocess

func (p *HookdeckProvider) Preprocess(newDestination *models.Destination, originalDestination *models.Destination, opts *destregistry.PreprocessDestinationOpts) error

Preprocess sets defaults and standardizes values

func (*HookdeckProvider) Validate

func (p *HookdeckProvider) Validate(ctx context.Context, destination *models.Destination) error

Validate performs destination-specific validation including token format

type HookdeckPublisher

type HookdeckPublisher struct {
	*destregistry.BasePublisher
	// contains filtered or unexported fields
}

Publisher implementation

func NewPublisher

func NewPublisher(tokenString string, opts ...PublisherOption) (*HookdeckPublisher, error)

NewPublisher creates a new HookdeckPublisher with the provided token and options

func (*HookdeckPublisher) Close

func (p *HookdeckPublisher) Close() error

Close closes any connections or resources

func (*HookdeckPublisher) Format

func (p *HookdeckPublisher) Format(ctx context.Context, event *models.Event) (*http.Request, error)

Format is a helper method that formats an event into an HTTP request for Hookdeck

func (*HookdeckPublisher) Publish

Publish publishes an event to the Hookdeck destination

type HookdeckSourceResponse

type HookdeckSourceResponse struct {
	Name       string     `json:"name"`
	URL        string     `json:"url"`
	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	DisabledAt *time.Time `json:"disabled_at"`
}

HookdeckSourceResponse represents the response from the Hookdeck API for source verification

func VerifyHookdeckToken

func VerifyHookdeckToken(client *http.Client, ctx context.Context, token *HookdeckToken) (*HookdeckSourceResponse, error)

VerifyHookdeckToken makes an API call to Hookdeck to verify the token and get the source information This function can be used to verify if a token is valid by making an API call to Hookdeck

type HookdeckToken

type HookdeckToken struct {
	ID         string
	SigningKey string // This is the original full token
}

HookdeckToken represents the decoded Hookdeck token

func ParseHookdeckToken

func ParseHookdeckToken(token string) (*HookdeckToken, error)

ParseHookdeckToken parses a Hookdeck token from the base64 encoded string

type ProviderOption

type ProviderOption func(*HookdeckProvider)

ProviderOption defines a function that configures a HookdeckProvider

func WithHTTPClient

func WithHTTPClient(client *http.Client) ProviderOption

WithHTTPClient sets a custom HTTP client for all publishers created by this provider

func WithUserAgent

func WithUserAgent(userAgent string) ProviderOption

WithUserAgent sets the user agent for the hookdeck request

type PublisherOption

type PublisherOption func(*HookdeckPublisher)

PublisherOption defines a function that configures a HookdeckPublisher

func PublisherWithClient

func PublisherWithClient(client *http.Client) PublisherOption

PublisherWithClient sets a custom HTTP client for the publisher

Jump to

Keyboard shortcuts

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