webhook

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeJson string = "application/json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Blueprint

type Blueprint struct {
	ID          string
	Endpoint    string
	Method      string
	Auth        string
	Schema      string
	ContentType string
}

type Logger

type Logger interface {
	Info(msg string, args ...any)
	Error(msg string, args ...any)
}

type Option

type Option func(*Webhook)

func WithAuth

func WithAuth(token string) Option

func WithDefault

func WithDefault() Option

func WithID

func WithID(id uuid.UUID) Option

func WithLogger

func WithLogger(l Logger) Option

func WithMethod

func WithMethod(method string) Option

func WithSchema

func WithSchema(schema string, contentType string) (Option, error)

func WithTimeout

func WithTimeout(d time.Duration) Option

type Webhook

type Webhook struct {
	http.Client
	// contains filtered or unexported fields
}

func FromBlueprint

func FromBlueprint(bp Blueprint, defaults ...Option) (*Webhook, error)

func New

func New(endpoint string, options ...Option) Webhook

func (Webhook) ID

func (e Webhook) ID() WebhookID

func (Webhook) IntoBlueprint

func (w Webhook) IntoBlueprint() Blueprint

IntoBlueprint returns a Blueprint that is reconstructable this Webhook.

func (Webhook) PrepareRequest

func (w Webhook) PrepareRequest(t session.Transaction) (*http.Request, error)

PrepareRequest returns the `http.Request` or an error using `session.Transaction`.

func (Webhook) Send

func (w Webhook) Send(t session.Transaction) error

type WebhookID

type WebhookID uuid.UUID

func (WebhookID) String

func (i WebhookID) String() string

String returns an uuid as string e.g. 271be94b-36d1-802e-d200-c1e0b85580b2

Jump to

Keyboard shortcuts

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