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 ¶
- func Form(body []byte, setForm map[string]string, removeForm []string) ([]byte, error)
- func JSON(body []byte, setJSON map[string]interface{}, removeJSON []string) ([]byte, error)
- func ParseHeaders[H any](block []byte, mk func(name, value string, raw []byte) H) []H
- func Query(query string, remove, set []string) string
- func RenderHeaders[H any](hs []H, name, value func(H) string) []byte
- func ReplaceCaseInsensitive(input []byte, match, replace string) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Form ¶
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 ¶
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
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
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
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
ReplaceCaseInsensitive replaces every occurrence of match in input using ASCII-only case folding, leaving non-ASCII bytes unchanged.
Types ¶
This section is empty.