mutate

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package mutate hosts the shared request-mutation and match/replace helpers used by replay, origination, and rule application across in-process and sidecar-owned flows. It depends only on the standard library and go-analyze/bulk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Form

func Form(body []byte, setForm map[string]string, removeForm []string) ([]byte, error)

Form applies set/remove edits to an application/x-www-form-urlencoded body and returns the re-encoded result. Output is key-sorted for stable diffing.

func JSON

func JSON(body []byte, setJSON map[string]interface{}, removeJSON []string) ([]byte, error)

JSON applies set/remove edits to a JSON body using the map form ({"key": value, "nested.key": value}) and returns the re-encoded result. Returns an error if body is not valid JSON.

func ParseHeaders added in v0.2.0

func ParseHeaders[H any](block []byte, mk func(name, value string, raw []byte) H) []H

ParseHeaders parses a rendered header block back into headers, keeping colon-less lines and passing each line's verbatim bytes to mk. mk builds one header from the parsed name, value (past the conventional one space), and raw line.

func Query added in v0.2.0

func Query(query string, remove, set []string) string

Query applies remove-then-set edits to a raw query string without parsing, preserving parameter order and percent-encoding. remove holds param names; set holds "key=value" entries.

func RenderHeaders added in v0.2.0

func RenderHeaders[H any](hs []H, name, value func(H) string) []byte

RenderHeaders serializes headers as "Name: Value\r\n" lines for match/replace rule application. name and value extract each field from the caller's header type.

func ReplaceCaseInsensitive added in v0.2.0

func ReplaceCaseInsensitive(input []byte, match, replace string) []byte

ReplaceCaseInsensitive replaces every occurrence of match in input using ASCII-only case folding, leaving non-ASCII bytes unchanged.

Types

This section is empty.

Jump to

Keyboard shortcuts

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