webhook

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package webhook provides a generic webhook interface for receiving external events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Source  string            `json:"source"`
	Type    string            `json:"type"`
	Body    json.RawMessage   `json:"body"`
	Headers map[string]string `json:"headers,omitempty"`
}

Event represents an incoming webhook event.

type Handler

type Handler func(ctx context.Context, event Event) error

Handler processes webhook events.

type Server

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

Server manages webhook endpoints and routes events to handlers.

func NewServer

func NewServer(secret string) *Server

NewServer creates a webhook server. secret is optional; if provided, it validates X-Webhook-Secret header.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the HTTP handler for mounting.

func (*Server) On

func (s *Server) On(eventType string, h Handler)

On registers a handler for a specific event type.

Jump to

Keyboard shortcuts

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