vtl

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 14 Imported by: ? 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvalJSONPath

func EvalJSONPath(root any, path string) any

EvalJSONPath evaluates a JSONPath expression against a ParseOrderedJSON root.

func JavaString

func JavaString(v any) string

JavaString renders a template value the way Java's toString would.

func MapGet

func MapGet(root any, key string) (any, bool)

MapGet looks key up in a ParseOrderedJSON object; ok is false for non-objects or absent keys.

func ParseOrderedJSON

func ParseOrderedJSON(s string) (any, error)

ParseOrderedJSON decodes JSON into template values (insertion-ordered maps).

func Render

func Render(tmpl string, ctx Context) string

Render renders a Velocity template, returning it unchanged when it does not parse.

func RenderStrict

func RenderStrict(tmpl string, ctx Context) (string, error)

RenderStrict renders a Velocity template with API Gateway's mapping objects ($input, $context, $stageVariables, $util), returning an error for a template that does not parse.

Types

type Context

type Context struct {
	// StageVariables is exposed as $stageVariables.X.
	StageVariables map[string]string
	// Authorizer is exposed as $context.authorizer.
	Authorizer map[string]any
	// Extra adds further $context.<key> entries (e.g. WebSocket connectionId, routeKey).
	Extra map[string]any
	// Headers, QueryParams and PathParams feed $input.params().
	Headers     map[string]string
	QueryParams map[string]string
	PathParams  map[string]string
	// Body is the raw request body passed as $input.body.
	Body string
	// RequestID is exposed as $context.requestId.
	RequestID string
	// HTTPMethod is exposed as $context.httpMethod.
	HTTPMethod string
	// ResourcePath is exposed as $context.resourcePath (the route template, e.g. /users/{id}).
	ResourcePath string
	// Path is exposed as $context.path (the actual request path).
	Path string
	// Stage is exposed as $context.stage.
	Stage string
	// APIID is exposed as $context.apiId.
	APIID string
	// AccountID is exposed as $context.accountId.
	AccountID string
	// DomainName is exposed as $context.domainName.
	DomainName string
	// SourceIP is exposed as $context.identity.sourceIp.
	SourceIP string
	// UserAgent is exposed as $context.identity.userAgent.
	UserAgent string
}

Context holds the context variables available during VTL template rendering.

Jump to

Keyboard shortcuts

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