selector

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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)
body                   raw body
body.$                 whole body as JSON
body.$.<path>          JSONPath-like subset, e.g. body.$.items[0].id
duration               round-trip time in milliseconds

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Select

func Select(resp *Response, sel string) (value string, ok bool, err error)

Select evaluates sel against resp. ok=false means the selector was valid but nothing was there (missing header or JSON path).

func ToGJSON

func ToGJSON(tail string) string

ToGJSON converts a JSONPath-like tail such as `.items[0].id` or `["key with space"]` into a gjson path (`items.0.id`).

Types

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.

Jump to

Keyboard shortcuts

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