webhooks

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package webhooks provides HTTP handlers for webhook management endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateWebhookRequest

type CreateWebhookRequest struct {
	URL      string                 `json:"url" validate:"required,url"`
	Events   []string               `json:"events,omitempty"` // Empty means all events
	Secret   string                 `json:"secret,omitempty"`
	Headers  map[string]string      `json:"headers,omitempty"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

CreateWebhookRequest represents a request to create a webhook.

type DeliveryResponse

type DeliveryResponse struct {
	ID          string  `json:"id"`
	WebhookID   string  `json:"webhook_id"`
	EventID     string  `json:"event_id"`
	EventType   string  `json:"event_type"`
	URL         string  `json:"url"`
	StatusCode  int     `json:"status_code"`
	Duration    int64   `json:"duration_ms"`
	Attempts    int     `json:"attempts"`
	Success     bool    `json:"success"`
	Error       string  `json:"error,omitempty"`
	DeliveredAt string  `json:"delivered_at"`
	NextRetryAt *string `json:"next_retry_at,omitempty"`
}

DeliveryResponse represents a webhook delivery in API responses.

type ErrorResponse

type ErrorResponse struct {
	Error   string            `json:"error"`
	Details map[string]string `json:"details,omitempty"`
}

ErrorResponse represents an error response.

type Handler

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

Handler provides HTTP handlers for webhook operations.

func NewHandler

func NewHandler(webhookService *service.WebhookService) *Handler

NewHandler creates a new webhook handler.

func (*Handler) Create

func (h *Handler) Create(w http.ResponseWriter, r *http.Request)

Create handles POST /api/v1/webhooks

func (*Handler) Delete

func (h *Handler) Delete(w http.ResponseWriter, r *http.Request)

Delete handles DELETE /api/v1/webhooks/{id}

func (*Handler) Get

func (h *Handler) Get(w http.ResponseWriter, r *http.Request)

Get handles GET /api/v1/webhooks/{id}

func (*Handler) List

func (h *Handler) List(w http.ResponseWriter, r *http.Request)

List handles GET /api/v1/webhooks

func (*Handler) ListDeliveries

func (h *Handler) ListDeliveries(w http.ResponseWriter, r *http.Request)

ListDeliveries handles GET /api/v1/webhooks/{id}/deliveries

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(r chi.Router)

RegisterRoutes registers all webhook routes on the given router.

func (*Handler) RetryDelivery

func (h *Handler) RetryDelivery(w http.ResponseWriter, r *http.Request)

RetryDelivery handles POST /api/v1/webhooks/deliveries/{id}/retry

func (*Handler) Test

func (h *Handler) Test(w http.ResponseWriter, r *http.Request)

Test handles POST /api/v1/webhooks/{id}/test

func (*Handler) Update

func (h *Handler) Update(w http.ResponseWriter, r *http.Request)

Update handles PUT /api/v1/webhooks/{id}

type ListDeliveriesResponse

type ListDeliveriesResponse struct {
	Deliveries []DeliveryResponse `json:"deliveries"`
	Total      int                `json:"total"`
	Limit      int                `json:"limit"`
	Offset     int                `json:"offset"`
}

ListDeliveriesResponse represents a paginated list of deliveries.

type ListWebhooksResponse

type ListWebhooksResponse struct {
	Webhooks []WebhookResponse `json:"webhooks"`
	Total    int               `json:"total"`
	Limit    int               `json:"limit"`
	Offset   int               `json:"offset"`
}

ListWebhooksResponse represents a paginated list of webhooks.

type UpdateWebhookRequest

type UpdateWebhookRequest struct {
	URL      *string                `json:"url,omitempty" validate:"omitempty,url"`
	Events   []string               `json:"events,omitempty"`
	Secret   *string                `json:"secret,omitempty"`
	Headers  map[string]string      `json:"headers,omitempty"`
	Active   *bool                  `json:"active,omitempty"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

UpdateWebhookRequest represents a request to update a webhook.

type WebhookResponse

type WebhookResponse struct {
	ID           string                 `json:"id"`
	URL          string                 `json:"url"`
	Events       []string               `json:"events"`
	Headers      map[string]string      `json:"headers,omitempty"`
	Active       bool                   `json:"active"`
	CreatedAt    string                 `json:"created_at"`
	UpdatedAt    string                 `json:"updated_at"`
	LastDelivery *string                `json:"last_delivery,omitempty"`
	FailureCount int                    `json:"failure_count"`
	Metadata     map[string]interface{} `json:"metadata,omitempty"`
}

WebhookResponse represents a webhook in API responses.

Jump to

Keyboard shortcuts

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