rule

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileRules

func CompileRules(rulesDir string, envs map[string]string) ([]*Rule, []*Rule, error)

func NewCelEnv

func NewCelEnv() (*cel.Env, error)

func ReusableReader

func ReusableReader(r io.Reader) io.Reader

ReusableReader reads the entire contents of r and returns a reader that can be consumed multiple times. Each time EOF is reached, the internal pointer is reset so subsequent reads start from the beginning again.

Types

type ActionEnum

type ActionEnum string
const (
	ActionEnumScript ActionEnum = "script"
	ActionEnumReject ActionEnum = "reject"
)

type ChangeTypeEnum

type ChangeTypeEnum string
const (
	ChangeTypeEnumRequest  ChangeTypeEnum = "request"
	ChangeTypeEnumResponse ChangeTypeEnum = "response"
)

type Rule

type Rule struct {
	Name           string         `yaml:"name"`
	Change         ChangeTypeEnum `yaml:"change"`
	Enabled        bool           `yaml:"enabled"`
	Rule           string         `yaml:"rule"`
	Action         ActionEnum     `yaml:"action"`
	Import         string         `yaml:"import"`
	Script         string         `yaml:"script"`
	CompiledScript func(*http.Request, *http.Response) error
	CompiledRule   cel.Program
}

func (*Rule) Apply

func (r *Rule) Apply(req *http.Request, resp *http.Response) error

func (*Rule) Check

func (r *Rule) Check(req *http.Request, res *http.Response) (bool, error)

Jump to

Keyboard shortcuts

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