replay

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveProvider

func ActiveProvider() string

func Disable

func Disable()

func Enable

func Enable(provider string)

func FirstNonEmpty added in v0.3.1

func FirstNonEmpty(values ...string) string

FirstNonEmpty returns the first trimmed non-empty value.

func IsActive

func IsActive() bool

func IsActiveForProvider

func IsActiveForProvider(provider string) bool

func JSONResponse added in v0.3.1

func JSONResponse(req *http.Request, statusCode int, payload any) *http.Response

JSONResponse builds a 200-style JSON response bound to req with the marshalled payload.

func NonEmptyStrings added in v0.3.1

func NonEmptyStrings(values ...string) []string

NonEmptyStrings returns trimmed copies of every non-empty input value.

func ParseInt added in v0.3.1

func ParseInt(value string, fallback int) int

ParseInt parses value or returns fallback when empty / unparsable / non-positive.

func ReadRequestBody added in v0.3.1

func ReadRequestBody(req *http.Request) ([]byte, error)

ReadRequestBody drains req.Body and rewires it so downstream handlers can read it again.

func Response added in v0.3.1

func Response(req *http.Request, statusCode int, contentType string, body []byte) *http.Response

Response is the shared response constructor used by JSONResponse / XMLResponse.

func SubtleEqual added in v0.3.1

func SubtleEqual(left, right string) bool

SubtleEqual reports whether two strings are equal in constant time.

func SupportedPayloads

func SupportedPayloads(provider string) []string

func SupportsProvider

func SupportsProvider(provider string) bool

func XMLResponse added in v0.3.1

func XMLResponse(req *http.Request, statusCode int, payload any) *http.Response

XMLResponse builds a response bound to req with the marshalled XML payload.

Types

type AuthFailureKind added in v0.3.1

type AuthFailureKind int

AuthFailureKind classifies the outcome of replay-side request authentication.

const (
	AuthOK AuthFailureKind = iota
	AuthInvalidAccessKey
	AuthInvalidSignature
)

type Credentials

type Credentials struct {
	AccessKey string
	SecretKey string
	// Extras carry additional option-key / value pairs needed to fully
	// configure providers that do not fit the AccessKey + SecretKey shape
	// (e.g. azure tenantId / subscriptionId, gcp base64Json). They are
	// surfaced in the demo replay banner alongside AccessKey / SecretKey.
	Extras []NamedValue
	// HideDefaultLabels suppresses the "AccessKey: …" / "SecretKey: …" rows
	// in the demo banner for providers whose auth model does not use those
	// labels (azure: clientId/clientSecret, gcp: base64Json). The struct
	// fields are still populated for replay transport / cache lookups; they
	// just shouldn't surface as user-facing copy targets when the operator
	// fills the form using native field names from Extras.
	HideDefaultLabels bool
}

func CredentialsFor

func CredentialsFor(provider string) (Credentials, bool)

type NamedValue added in v0.3.1

type NamedValue struct {
	Name  string
	Value string
}

NamedValue is a key/value pair used by demo replay banners and option-fill helpers to advertise extra credential fields.

type State

type State struct {
	Active   bool
	Provider string
}

type Window added in v0.3.1

type Window struct {
	Start int
	End   int
}

Window is the half-open index range [Start, End) used to paginate fixtures.

func OffsetWindow added in v0.3.1

func OffsetWindow(total, offset, size int) Window

OffsetWindow computes the slice for offset/limit-style pagination.

func PageWindow added in v0.3.1

func PageWindow(total, pageNumber, pageSize int) Window

PageWindow computes the slice for 1-based pagination.

Jump to

Keyboard shortcuts

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