matchers

package
v1.2.13 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConditionTypes = map[string]ConditionType{
	"and": ANDCondition,
	"or":  ORCondition,
}
View Source
var MatcherTypes = map[MatcherType]string{
	StatusMatcher: "status",
	SizeMatcher:   "size",
	WordsMatcher:  "word",
	RegexMatcher:  "regex",
	BinaryMatcher: "binary",
	DSLMatcher:    "dsl",
}

MatcherTypes is a table for conversion of matcher type from string.

Functions

This section is empty.

Types

type ConditionType

type ConditionType int
const (
	ANDCondition ConditionType = iota + 1
	ORCondition
)

type Matcher

type Matcher struct {
	Name            string            `json:"name,omitempty"`
	Type            MatcherTypeHolder `yaml:"type" json:"type"`
	Words           []string          `yaml:"words" json:"words,omitempty"`
	Part            string            `yaml:"part" json:"part,omitempty"`
	Regex           []string          `yaml:"regex" json:"regex,omitempty"`
	Encoding        string            `yaml:"encoding" json:"encoding,omitempty"`
	MatchAll        bool              `yaml:"matchAll" json:"match_all,omitempty"`
	Condition       string            `yaml:"condition" json:"condition,omitempty"`
	Group           int               `yaml:"group"`
	Status          []int             `` /* 127-byte string literal not displayed */
	CaseInsensitive bool              `` /* 152-byte string literal not displayed */

	HasExtra bool
	// contains filtered or unexported fields
}

func (*Matcher) CompileMatchers

func (matcher *Matcher) CompileMatchers() error

CompileMatchers performs the initial setup operation on a matcher

func (*Matcher) GetType

func (matcher *Matcher) GetType() MatcherType

GetType returns the type of the matcher

func (*Matcher) MatchRegex

func (matcher *Matcher) MatchRegex(corpus string) (bool, []string)

MatchRegex matches a regex check against a corpus

func (*Matcher) MatchStatusCode

func (matcher *Matcher) MatchStatusCode(statusCode int) bool

MatchStatusCode matches a status code check against a corpus

func (*Matcher) MatchWords

func (matcher *Matcher) MatchWords(corpus string) (bool, []string)

MatchWords matches a word check against a corpus.

type MatcherType

type MatcherType int

MatcherType is the type of the matcher specified

const (
	// name:word
	WordsMatcher MatcherType = iota + 1
	// name:regex
	RegexMatcher
	// name:binary
	BinaryMatcher
	// name:status
	StatusMatcher
	// name:size
	SizeMatcher
	// name:dsl
	DSLMatcher
)

name:MatcherType

func GetSupportedMatcherTypes

func GetSupportedMatcherTypes() []MatcherType

GetSupportedMatcherTypes returns list of supported types

func (MatcherType) String

func (t MatcherType) String() string

type MatcherTypeHolder

type MatcherTypeHolder struct {
	MatcherType MatcherType `mapping:"true"`
}

MatcherTypeHolder is used to hold internal type of the matcher

func (MatcherTypeHolder) JSONSchemaType

func (holder MatcherTypeHolder) JSONSchemaType() *jsonschema.Type

func (MatcherTypeHolder) MarshalJSON

func (holder MatcherTypeHolder) MarshalJSON() ([]byte, error)

func (MatcherTypeHolder) MarshalYAML

func (holder MatcherTypeHolder) MarshalYAML() (interface{}, error)

func (MatcherTypeHolder) String

func (t MatcherTypeHolder) String() string

func (*MatcherTypeHolder) UnmarshalYAML

func (holder *MatcherTypeHolder) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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