filter

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package filter applies shorthand or jq expressions to a response value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(expr string, doc map[string]any, lang Lang) (any, error)

Apply runs expr against doc using the chosen language and returns the result. doc should be a map[string]any with keys "body", "headers", "headers_all", "links", "status", "proto" — i.e. the full normalised Response map.

Types

type Lang

type Lang int

Lang selects which query language to use.

const (
	// LangAuto detects the language from the expression (default).
	LangAuto Lang = iota
	// LangShorthand forces shorthand query syntax.
	LangShorthand
	// LangJQ forces jq syntax.
	LangJQ
)

func (Lang) String

func (l Lang) String() string

type Result

type Result struct {
	Value any
	Lang  Lang
}

Result is a filtered value with metadata about how the filter was evaluated.

func ApplyWithInfo

func ApplyWithInfo(expr string, doc map[string]any, lang Lang) (Result, error)

ApplyWithInfo runs expr against doc and returns the filtered value plus the language that was ultimately used.

Jump to

Keyboard shortcuts

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