model

package
v0.0.0-...-9149657 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Method       string              `json:"method"`
	Path         string              `json:"path"`
	Query        string              `json:"query,omitempty"`
	Payload      string              `json:"payload"`
	Headers      map[string][]string `json:"headers"`
	Time         time.Time           `json:"time"`
	StatusCode   int                 `json:"statusCode"`
	ErrorMessage string              `json:"error,omitempty"`
}

Message represents a webhook message

func NewMessage

func NewMessage(method string, path string, query string, payload string, headers map[string][]string) *Message

NewMessage creates a new message with the current timestamp.

func (*Message) MarkRejected

func (m *Message) MarkRejected(statusCode int, errorMessage string)

MarkRejected stores the receiver response for a rejected delivery attempt.

func (*Message) Rejected

func (m *Message) Rejected() bool

Rejected indicates whether the captured delivery was rejected by the receiver.

type MessageOutcome

type MessageOutcome string

MessageOutcome filters captured messages by delivery result.

const (
	// MessageOutcomeAll returns every captured message.
	MessageOutcomeAll MessageOutcome = "all"
	// MessageOutcomeAccepted returns only successful deliveries.
	MessageOutcomeAccepted MessageOutcome = "accepted"
	// MessageOutcomeRejected returns only rejected deliveries.
	MessageOutcomeRejected MessageOutcome = "rejected"
)

func ParseMessageOutcome

func ParseMessageOutcome(value string) (MessageOutcome, bool)

ParseMessageOutcome validates and normalizes the requested outcome filter.

type MessagePage

type MessagePage struct {
	Messages        []*Message `json:"messages"`
	Page            int        `json:"page"`
	PageSize        int        `json:"pageSize"`
	TotalMessages   int        `json:"totalMessages"`
	TotalPages      int        `json:"totalPages"`
	HasNextPage     bool       `json:"hasNextPage"`
	HasPreviousPage bool       `json:"hasPreviousPage"`
}

MessagePage represents a single page of captured webhook messages.

type Webhook

type Webhook struct {
	Username string `json:"username,omitempty"`

	TokenName string `json:"tokenName,omitempty"`

	HMACHeader string `json:"hmacHeader,omitempty"`

	ID        string    `json:"id"`
	ExpiresAt time.Time `json:"expiresAt"`
	// contains filtered or unexported fields
}

Webhook is the validated runtime representation of a configured receiver.

func NewStoredWebhook

func NewStoredWebhook(id string, username string, passwordHash string, tokenName string, tokenValueHash string, hmacHeader string, hmacSecret string, expiresAt time.Time) *Webhook

NewStoredWebhook reconstructs a webhook from persisted storage values.

func NewWebhook

func NewWebhook(username string, password string, tokenName string, tokenValue string, hmacHeader string, hmacSecret string) *Webhook

NewWebhook creates webhook based on input

func NewWebhookFromInput

func NewWebhookFromInput(webhookInput *WebhookInput) *Webhook

NewWebhookFromInput creates Webhook instance based on input

func (*Webhook) AuthorizationFailure

func (w *Webhook) AuthorizationFailure(r *http.Request, body []byte) string

AuthorizationFailure returns a human-readable authorization failure or an empty string on success.

func (*Webhook) HMACSecret

func (w *Webhook) HMACSecret() string

HMACSecret returns the configured HMAC secret.

func (*Webhook) HasBasicAuth

func (w *Webhook) HasBasicAuth() bool

HasBasicAuth indicates whether basic auth is configured for the webhook.

func (*Webhook) HasHMAC

func (w *Webhook) HasHMAC() bool

HasHMAC indicates whether HMAC validation is configured.

func (*Webhook) HasHeaderToken

func (w *Webhook) HasHeaderToken() bool

HasHeaderToken indicates whether header token validation is configured.

func (*Webhook) PasswordHash

func (w *Webhook) PasswordHash() string

PasswordHash returns the stored password hash.

func (*Webhook) TokenValueHash

func (w *Webhook) TokenValueHash() string

TokenValueHash returns the stored header-token hash.

func (*Webhook) Validate

func (w *Webhook) Validate() error

Validate validates whether token and/or username are correctly provided

func (*Webhook) ValidateAuthorization

func (w *Webhook) ValidateAuthorization(r *http.Request, body []byte) bool

ValidateAuthorization validates authorization based on provided request

func (*Webhook) ValidateReadAuthorization

func (w *Webhook) ValidateReadAuthorization(r *http.Request) bool

ValidateReadAuthorization validates the auth schemes that can sensibly protect reads.

type WebhookInput

type WebhookInput struct {
	Username   string `json:"username,omitempty"`
	Password   string `json:"password,omitempty"`
	TokenName  string `json:"tokenName,omitempty"`
	TokenValue string `json:"tokenValue,omitempty"`
	HMACHeader string `json:"hmacHeader,omitempty"`
	HMACSecret string `json:"hmacSecret,omitempty"`
}

WebhookInput is used for unmarshaling user input.

Jump to

Keyboard shortcuts

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