engine

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine is the core webhook processing engine.

func New

func New(configs []*config.RuleConfig, log *logger.Logger) *Engine

New creates a new Engine instance.

func (*Engine) Process

func (e *Engine) Process(req *RequestData) []Response

Process handles an incoming webhook request by iterating all configs. Stops at the first matching rule (first match wins).

func (*Engine) ProcessAll

func (e *Engine) ProcessAll(req *RequestData) []Response

ProcessAll iterates all configs and executes ALL matching rules (not just first match).

func (*Engine) ProcessTargeted

func (e *Engine) ProcessTargeted(cfg *config.RuleConfig, req *RequestData) []Response

ProcessTargeted handles a webhook request for a specific config file (by filename).

func (*Engine) UpdateConfigs

func (e *Engine) UpdateConfigs(configs []*config.RuleConfig)

UpdateConfigs replaces the engine's rule configs (for hot reload).

type RequestData

type RequestData struct {
	Headers   map[string]string
	Query     map[string]string
	Body      map[string]interface{}
	BodyRaw   string
	BodyBytes []byte // raw body bytes for HMAC signature verification
	IP        string
}

RequestData holds parsed request information.

func ParseRequest

func ParseRequest(r *http.Request) *RequestData

ParseRequest extracts RequestData from an HTTP request.

type Response

type Response struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Config  string `json:"config,omitempty"`
	Rule    string `json:"rule,omitempty"`
	Actions int    `json:"actions,omitempty"`
}

Response is the standard JSON response structure.

Jump to

Keyboard shortcuts

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