Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Defs []*MatchDef `json:"pattern_list" yaml:"pattern_list"` Vars map[string]interface{} `json:"vars" yaml:"vars"` }
Config represents an imPOSTer configuration. A set of rule expressions can be defined dy Defs field.
func ReadConfig ¶
ReadConfig takes a path as an input and parses its content to build the imPOSTer configuration.
type MatchDef ¶
type MatchDef struct { RuleExpression string `json:"rule_expression" yaml:"rule_expression"` Latency time.Duration `json:"latency" yaml:"latency"` Response interface{} `json:"response" yaml:"response"` }
MatchDef represents a single rule expression. The RuleExpression field wraps a boolean expression every incoming HTTP request is matched against. How a matching rule expression should be managed is defined by the Response object.
type MatchRsp ¶
type MatchRsp struct { Body string `mapstructure:"body"` Headers map[string]interface{} `mapstructure:"headers"` StatusCode string `mapstructure:"status_code"` }
MatchRsp is the fully structured version of a Response object. Body represents the payload to be returned and it can be an expression as well. Headers is a collection of HTTP headers to be returned and each entry can be an expression. StatusCode represents the resulting HTTP status code and it MUST be an expression:
rsp := MatchRsp{Body: "some content", StatusCode: `${200}`}
func (*MatchRsp) ParseHeaders ¶
func (rsp *MatchRsp) ParseHeaders(parse functions.ExpressionParser) (map[string]functions.Expression, error)
ParseHeaders evaluates any HTTP header and returns an expression for each of them. It returns an error in case of evaluation failures.
func (*MatchRsp) ParseStatusCode ¶
func (rsp *MatchRsp) ParseStatusCode(parse functions.ExpressionParser) (functions.Expression, error)
ParseStatusCode evaluates the resulting status code expression to an integer. It returns an error in case of evaluation failures.