Documentation
¶
Overview ¶
Package selector extracts values from an HTTP response using the small selector language shared by `# @capture` and `# @assert`:
status response status code
statusText e.g. "OK"
header.<name> first value of a response header (case-insensitive)
header.<name>.# how many values it has; header.<name>[1] the second
cookie.<name> value of a cookie the response set (Set-Cookie)
body raw body
body.$ whole body as JSON
body.$.<path> JSONPath: body.$.items[0].id, body.$..id,
body.$.items[?(@.done == true)].id, [-1], [1:3],
.# and .length; see path.go
duration round-trip time in milliseconds
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check parses a selector without a response, so validate reports a bad one before anything is sent. The error names what could not be read.
Types ¶
type Kind ¶
type Kind int
Kind is the JSON type of a selected value. Status, duration and counts are numbers; headers, cookies, statusText and the raw body are strings; a body path has the type of what it selects, and a set of matches is an array.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path is a parsed body path.
type Response ¶
type Response struct {
Status int
StatusText string
Headers http.Header
Body []byte
Duration time.Duration
}
Response is the subset of an HTTP response the selector language sees.
type UnknownError ¶
type UnknownError struct{ Selector string }
UnknownError is a selector that is none of the known forms (as opposed to a known form whose body path cannot be read).
func (*UnknownError) Error ¶
func (e *UnknownError) Error() string