webhook

package
v0.5.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWebhookPathRequired                = errors.New("webhook path is required")
	ErrSupportedEventsRequired            = errors.New("supported events are required")
	ErrInvalidWebhookAuthenticationConfig = errors.New("invalid webhook authentication configuration")
	ErrMissingRequest                     = errors.New("missing request for webhook authentication check")
)
View Source
var (
	ErrUnmarshalEvent           = errors.New("error unmarshaling event")
	ErrUnsupportedWebhookEvent  = errors.New("unsupported webhook event")
	ErrUnsupportedContentType   = errors.New("unsupported content type for webhook request")
	ErrFailedToParseContentType = errors.New("failed to parse content type")
	ErrFailsToParseBody         = errors.New("failed to parse body")
)
View Source
var (
	ErrMissingFieldID = errors.New("missing id field in event")
)

Functions

func GetEventTypeByPath added in v0.3.0

func GetEventTypeByPath(path string) func(data EventTypeParam) string

func GetPrimaryKeyByPath added in v0.2.0

func GetPrimaryKeyByPath(path string) func(parsedData gjson.Result) entities.PkFields

func SetupService

func SetupService[T Authentication](
	ctx context.Context,
	router *swagger.Router[fiber.Handler, fiber.Router],
	config Configuration[T],
	p pipeline.IPipelineGroup,
) error

Types

type Authentication

type Authentication interface {
	CheckSignature(req ValidatingRequest) error
	Validate() error
}

type Configuration

type Configuration[T Authentication] struct {
	// Secret the webhook secret configuration for validating the data received
	Authentication T      `json:"authentication"`
	WebhookPath    string `json:"webhookPath"`

	Events *Events `json:"-"`
}

func (*Configuration[T]) CheckSignature added in v0.2.0

func (c *Configuration[T]) CheckSignature(req ValidatingRequest) error

func (*Configuration[T]) Validate

func (c *Configuration[T]) Validate() error

type ContentTypeConfig added in v0.3.0

type ContentTypeConfig map[string]string

ContentTypeConfig allows configuring how to extract the payload field for a given content-type

type Event

type Event struct {
	Operation  entities.Operation
	GetFieldID func(parsedData gjson.Result) entities.PkFields
}

type EventTypeParam added in v0.3.0

type EventTypeParam struct {
	Data    gjson.Result
	Headers http.Header
}

type Events

type Events struct {
	Supported    map[string]Event
	GetEventType func(data EventTypeParam) string
	PayloadKey   ContentTypeConfig
}

type RequestInfo added in v0.3.0

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

type ValidatingRequest

type ValidatingRequest interface {
	GetReqHeaders() map[string][]string
	Body() []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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