exparam

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Pattern = regexp.MustCompile(`\$([\w\.]*)\(([\w.]+)\)`)
)

Functions

func Expand

func Expand(expr string, body []byte) (string, error)

Expand expands params of "$(body.x.y.z)" in the expression.

The param can be prefixed by a chain of functions. The form is like: $f1.f2(body.x.y.z)

func ExpandWithPath

func ExpandWithPath(expr string, path string, body []byte) (string, error)

ExpandWithPath expands params of either "$(path)", or "$(body.x.y.z)" in the expression.

Especially, for "body" params, it can be prefixed by a chain of functions. The form is like: $f1.f2(body.x.y.z) By defaults, the "escape" is applied. Otherwise, if explicitly defined a function, the "escape" won't be applied automatically, and need manually define if needed.

Types

type Func

type Func func(string) (string, error)

type FuncFactory

type FuncFactory struct {
	// contains filtered or unexported fields
}

func (FuncFactory) Build

func (f FuncFactory) Build() map[FuncName]Func

type FuncName

type FuncName string
const (
	FuncEscape   FuncName = "escape"
	FuncUnEscape FuncName = "unescape"
	FuncBase     FuncName = "base"
	FuncURLPath  FuncName = "url_path"
	FuncTrimPath FuncName = "trim_path"
)

Jump to

Keyboard shortcuts

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