publishers

package
v0.0.0-...-4faa728 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuiltinErrorAsserts = builtinErrorAsserts{}

Functions

func Save

func Save(db *sql.DB, hook Hook) error

func WebhookPublisherIgnoreDuplicates

func WebhookPublisherIgnoreDuplicates(errorAsserts ErrorAsserts) func(*WebhookPublisher)

func WebhookPublisherSecret

func WebhookPublisherSecret(secret string) func(*WebhookPublisher)

func WebhookPublisherStatusAccepted

func WebhookPublisherStatusAccepted(status int) func(*WebhookPublisher)

func WebhookPublisherStatusCreated

func WebhookPublisherStatusCreated(status int) func(*WebhookPublisher)

Types

type ErrorAsserts

type ErrorAsserts interface {
	IsDuplicateDatabaseEntry(error) bool
}

ErrorAsserts defines the error assertions used by publishers

type Hook

type Hook struct {
	EventID        string
	EventCreatedAt time.Time
	EventSource    string
	EventUUID      string
	Model          string
	Type           string
	Action         string
	UserID         string
	ModelData      string
	SourceData     string
}

type Parser

type Parser interface {
	Parse(request WebhookRequest, secret string) (hook *Hook, err error)
}

type ParserFunc

type ParserFunc func(request WebhookRequest, secret string) (hook *Hook, err error)

The ParserFunc type is an adapter to allow the use of ordinary functions as Parsers. If f is a function with the appropriate signature, ParserFunc(f) is a Parser that returns f(request, secret).

func (ParserFunc) Parse

func (f ParserFunc) Parse(request WebhookRequest, secret string) (hook *Hook, err error)

Parse returns f(request, secret).

type WebhookPublisher

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

func NewWebhookPublisher

func NewWebhookPublisher(db *sql.DB, parser Parser, options ...func(*WebhookPublisher)) WebhookPublisher

func (WebhookPublisher) Receive

func (p WebhookPublisher) Receive(w http.ResponseWriter, r *http.Request) (status int, err error)

type WebhookRequest

type WebhookRequest struct {
	Path                  string
	HTTPMethod            string
	Headers               map[string][]string
	QueryStringParameters map[string][]string
	Body                  []byte
	BodyUnicode           string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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