Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - Variables
 - func ApplyExpression(r *kong.Route, m Matcher, priority uint64)
 - type AndMatcher
 - type BinaryOperator
 - type FieldType
 - type HTTPHeaderField
 - type HTTPQueryField
 - type IntField
 - type IntLiteral
 - type LHS
 - type Literal
 - type LiteralType
 - type Matcher
 - type OrMatcher
 - type Predicate
 - func NewPrediacteHTTPHost(op BinaryOperator, value string) Predicate
 - func NewPredicate(lhs LHS, op BinaryOperator, rhs Literal) (Predicate, error)
 - func NewPredicateHTTPHeader(key string, op BinaryOperator, value string) Predicate
 - func NewPredicateHTTPMethod(op BinaryOperator, value string) Predicate
 - func NewPredicateHTTPPath(op BinaryOperator, value string) Predicate
 - func NewPredicateHTTPQuery(key string, op BinaryOperator, value string) Predicate
 - func NewPredicateNetProtocol(op BinaryOperator, value string) Predicate
 - func NewPredicateTLSSNI(op BinaryOperator, value string) Predicate
 
- type StringField
 - type StringLiteral
 - type TransformLower
 
Constants ¶
const ( FieldTypeInt = iota FieldTypeString FieldTypeSingleIP FieldTypeIPCIDR )
Variables ¶
var ( ErrTypeNotMatch = errors.New("type does not match on sides of predicate") ErrOperatorInvalid = errors.New("operator is not valid for the types of sides of predicate") )
Functions ¶
Types ¶
type AndMatcher ¶
type AndMatcher struct {
	// contains filtered or unexported fields
}
    func And ¶
func And(matchers ...Matcher) *AndMatcher
And constructs an AndMatcher from a list of Matchers. If any of the given Matchers is empty, And skips adding it.
func (*AndMatcher) And ¶
func (m *AndMatcher) And(matcher Matcher) *AndMatcher
And appends an additional Matcher to an existing AndMatcher. If the given Matcher is empty, it returns the original AndMatcher.
func (*AndMatcher) Expression ¶
func (m *AndMatcher) Expression() string
func (*AndMatcher) IsEmpty ¶
func (m *AndMatcher) IsEmpty() bool
type BinaryOperator ¶
type BinaryOperator string
BinaryOperator is an operator that accepts two arguments within a predicate expression.
const ( OpEqual BinaryOperator = "==" OpNotEqual BinaryOperator = "!=" OpRegexMatch BinaryOperator = "~" OpPrefixMatch BinaryOperator = "^=" OpSuffixMatch BinaryOperator = "=^" OpIn BinaryOperator = "in" OpNotIn BinaryOperator = "not in" OpContains BinaryOperator = "contains" OpLessThan BinaryOperator = "<" OpLessEqual BinaryOperator = "<=" OpGreaterThan BinaryOperator = ">" OpGreaterEqual BinaryOperator = ">=" )
type HTTPHeaderField ¶
type HTTPHeaderField struct {
	HeaderName string
}
    HTTPHeaderField extracts the value of an HTTP header from the request.
func (HTTPHeaderField) FieldType ¶
func (f HTTPHeaderField) FieldType() FieldType
func (HTTPHeaderField) String ¶
func (f HTTPHeaderField) String() string
type HTTPQueryField ¶
type HTTPQueryField struct {
	QueryParamName string
}
    HTTPQueryField extracts the value of an HTTP query parameter from the query string of the request.
func (HTTPQueryField) FieldType ¶
func (f HTTPQueryField) FieldType() FieldType
func (HTTPQueryField) String ¶
func (f HTTPQueryField) String() string
type IntField ¶
type IntField string
IntField is defined for fields with constant name and having integer type. The inner string value is the name of the field.
type IntLiteral ¶
type IntLiteral int
IntLiteral is an integer Literal.
func (IntLiteral) String ¶
func (l IntLiteral) String() string
func (IntLiteral) Type ¶
func (l IntLiteral) Type() LiteralType
type LHS ¶
type LHS interface {
	// FieldType returns the FieldType iota indicating the LHS type.
	FieldType() FieldType
	// String returns a string representation of the LHS.
	String() string
}
    LHS is the left hand side (the field) of a predicate expression.
type Literal ¶
type Literal interface {
	// Type returns the LiteralType iota indicating the Literal type.
	Type() LiteralType
	// String returns a string representation of the Literal.
	String() string
}
    Literal is the right hand side (the value) of a predicate expression.
type LiteralType ¶
type LiteralType int
const ( LiteralTypeInt LiteralType = iota LiteralTypeString // LiteralTypeIP is a type that represents a literal of a single IP address or an IP CIDR. // // TODO: define subtypes of IP literals(IPv4/IPv6;single IP/IP CIDR). LiteralTypeIP )
type Matcher ¶
type Matcher interface {
	// Expression returns a string representation of the Matcher that could be a valid Kong route expression.
	Expression() string
	// IsEmpty() returns a boolean indicating if the Matcher is empty. It is true if the Matcher is an empty struct,
	// if the Matcher has zero subMatchers, or if a single-predicate Matcher has no value.
	IsEmpty() bool
}
    Matcher is a sub-expression within a Kong router expression. It can be a single predicate expression, a group of predicates joined by logical operators, or a recursive combination of either of the previous components.
type OrMatcher ¶
type OrMatcher struct {
	// contains filtered or unexported fields
}
    OrMatcher is a group of Matchers joined by logical ORs.
func Or ¶
Or constructs an OrMatcher from a list of Matchers. If any of the given Matchers is empty, Or skips adding it.
func (*OrMatcher) Expression ¶
type Predicate ¶
type Predicate struct {
	// contains filtered or unexported fields
}
    Predicate is an expression consisting of two arguments and a comparison operator. Kong's expression router evaluates these to true or false.
func NewPrediacteHTTPHost ¶
func NewPrediacteHTTPHost(op BinaryOperator, value string) Predicate
func NewPredicate ¶
func NewPredicate(lhs LHS, op BinaryOperator, rhs Literal) (Predicate, error)
NewPredicate generates a single predicate.
func NewPredicateHTTPHeader ¶
func NewPredicateHTTPHeader(key string, op BinaryOperator, value string) Predicate
func NewPredicateHTTPMethod ¶
func NewPredicateHTTPMethod(op BinaryOperator, value string) Predicate
func NewPredicateHTTPPath ¶
func NewPredicateHTTPPath(op BinaryOperator, value string) Predicate
func NewPredicateHTTPQuery ¶
func NewPredicateHTTPQuery(key string, op BinaryOperator, value string) Predicate
func NewPredicateNetProtocol ¶
func NewPredicateNetProtocol(op BinaryOperator, value string) Predicate
func NewPredicateTLSSNI ¶
func NewPredicateTLSSNI(op BinaryOperator, value string) Predicate
func (Predicate) Expression ¶
Expression returns a string representation of a Predicate.
type StringField ¶
type StringField string
StringField is defined for fields with constant name and having string type. The inner string value is the name of the field.
const ( FieldNetProtocol StringField = "net.protocol" FieldTLSSNI StringField = "tls.sni" FieldHTTPMethod StringField = "http.method" FieldHTTPHost StringField = "http.host" FieldHTTPPath StringField = "http.path" )
func (StringField) FieldType ¶
func (f StringField) FieldType() FieldType
func (StringField) String ¶
func (f StringField) String() string
type StringLiteral ¶
type StringLiteral string
StringLiteral is a string Literal.
func (StringLiteral) String ¶
func (l StringLiteral) String() string
func (StringLiteral) Type ¶
func (l StringLiteral) Type() LiteralType
type TransformLower ¶
type TransformLower struct {
	// contains filtered or unexported fields
}
    TransformLower instructs Kong to transform a field (for example, http.path) to lowercase before comparing it to a value in a predicate expression. It can only be applied to the left side of a predicate expression.
func NewTransformerLower ¶
func NewTransformerLower(inner LHS) TransformLower
func (TransformLower) FieldType ¶
func (t TransformLower) FieldType() FieldType
func (TransformLower) String ¶
func (t TransformLower) String() string