Documentation
¶
Index ¶
- type Message
- type MessageOutcome
- type MessagePage
- type Webhook
- func (w *Webhook) AuthorizationFailure(r *http.Request, body []byte) string
- func (w *Webhook) HMACSecret() string
- func (w *Webhook) HasBasicAuth() bool
- func (w *Webhook) HasHMAC() bool
- func (w *Webhook) HasHeaderToken() bool
- func (w *Webhook) PasswordHash() string
- func (w *Webhook) TokenValueHash() string
- func (w *Webhook) Validate() error
- func (w *Webhook) ValidateAuthorization(r *http.Request, body []byte) bool
- func (w *Webhook) ValidateReadAuthorization(r *http.Request) bool
- type WebhookInput
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 ¶
MarkRejected stores the receiver response for a rejected delivery attempt.
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 ¶
AuthorizationFailure returns a human-readable authorization failure or an empty string on success.
func (*Webhook) HMACSecret ¶
HMACSecret returns the configured HMAC secret.
func (*Webhook) HasBasicAuth ¶
HasBasicAuth indicates whether basic auth is configured for the webhook.
func (*Webhook) HasHeaderToken ¶
HasHeaderToken indicates whether header token validation is configured.
func (*Webhook) PasswordHash ¶
PasswordHash returns the stored password hash.
func (*Webhook) TokenValueHash ¶
TokenValueHash returns the stored header-token hash.
func (*Webhook) ValidateAuthorization ¶
ValidateAuthorization validates authorization based on provided request
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.