response

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 2 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 response evaluates configurable HTTP response acceptance rules. It does not load configuration, perform HTTP requests, or log response bodies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSON

type JSON struct {
	// Pointer is an RFC 6901 JSON Pointer to the expected value; empty selects the root.
	Pointer string
	// Equals contains the expected JSON value, including its type.
	Equals json.RawMessage
	// ErrorPointer is an optional RFC 6901 pointer to a scalar error message.
	ErrorPointer string
}

JSON describes a typed JSON value match and optional error extraction.

type Rule

type Rule struct {
	// StatusCodes optionally overrides the accepted HTTP statuses.
	StatusCodes []int
	// Text validates a plain-text response when non-nil.
	Text *Text
	// JSON validates a JSON response when non-nil.
	JSON *JSON
}

Rule specifies accepted HTTP statuses and at most one body matcher. With no StatusCodes, HTTP 2xx is accepted. The zero value checks status only.

func (Rule) Clone

func (r Rule) Clone() Rule

Clone returns an independent copy of the rule and its mutable fields.

func (Rule) Evaluate

func (r Rule) Evaluate(statusCode int, body []byte) error

Evaluate checks the HTTP status and optional body matcher. Error details are extracted only through explicitly configured text or JSON matchers.

func (Rule) HasBodyMatcher

func (r Rule) HasBodyMatcher() bool

HasBodyMatcher reports whether evaluation requires a complete response body.

func (Rule) Validate

func (r Rule) Validate() error

Validate checks that a rule is structurally valid without inspecting a response.

type Text

type Text struct {
	// Equals requires the entire response body to equal the supplied value.
	Equals *string
	// Contains requires the response body to include the supplied value.
	Contains *string
}

Text describes one plain-text match; exactly one match must be selected.

Jump to

Keyboard shortcuts

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