webhook

package
v3.8.3-patch.18 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCallback

func RegisterCallback[Req any, Resp any](s *Server, command string, fn func(c *gin.Context, req *Req) (*Resp, error))

RegisterCallback registers a typed handler for a callback command.

Types

type RequestRecord

type RequestRecord struct {
	Timestamp time.Time
	Command   string
	Body      []byte
	Headers   http.Header
}

RequestRecord stores information about a received webhook request.

type Server

type Server struct {
	Engine *gin.Engine
	// contains filtered or unexported fields
}

Server is a mock webhook HTTP server for OpenIM callbacks.

func NewServer

func NewServer() *Server

NewServer creates a new mock webhook server instance.

func (*Server) ClearHistory

func (s *Server) ClearHistory()

ClearHistory clears all recorded request history.

func (*Server) GetHistory

func (s *Server) GetHistory() []RequestRecord

GetHistory returns a copy of all recorded requests.

func (*Server) OnRequest

func (s *Server) OnRequest(hook func(command string, reqBody []byte, c *gin.Context))

OnRequest sets a callback function invoked whenever any webhook request arrives.

func (*Server) RegisterDefaultHandlers

func (s *Server) RegisterDefaultHandlers()

RegisterDefaultHandlers registers default success handlers for all supported OpenIM webhook commands.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP conforms to the http.Handler interface.

func (*Server) SetRecordHistory

func (s *Server) SetRecordHistory(enabled bool)

SetRecordHistory enables or disables recording incoming request history.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully stops the running HTTP server.

func (*Server) Start

func (s *Server) Start(addr string) error

Start runs the webhook HTTP server on the given address (e.g. ":10006").

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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