Documentation
¶
Index ¶
- Constants
- Variables
- func Functions(ctx context.Context, reg pkgplugins.Registry) map[string]any
- func HasTemplatesInHeaders(headers map[string]string) bool
- func IsTemplateString(s string) bool
- type Data
- type Engine
- func (e *Engine) ProcessError(errorStr string, templateData Data) (string, error)
- func (e *Engine) ProcessHeaders(headers map[string]string, templateData Data) error
- func (e *Engine) ProcessMap(data map[string]any, templateData Data) error
- func (e *Engine) Render(tmpl string, data Data) (result string, err error)
Constants ¶
View Source
const (
MaxRecursionDepth = 250
)
MaxRecursionDepth is the maximum allowed nesting depth for ProcessMap/ProcessStream.
Variables ¶
View Source
var ErrMaxRecursionDepthExceeded = errors.New("maximum recursion depth exceeded")
ErrMaxRecursionDepthExceeded is returned when structure nesting exceeds MaxRecursionDepth.
Functions ¶
func HasTemplatesInHeaders ¶
HasTemplatesInHeaders reports whether any header value contains a template.
func IsTemplateString ¶
IsTemplateString checks if a string contains template syntax. The closing delimiter must appear AFTER the opening one — "a }} b {{ c" is not a template.
Types ¶
type Data ¶
type Data struct {
Request map[string]any `json:"request"`
Headers map[string]any `json:"headers"`
MessageIndex int `json:"messageIndex"`
RequestTime time.Time `json:"requestTime"`
// Timestamp is a backward-compatibility alias for RequestTime
Timestamp time.Time `json:"timestamp"`
State map[string]any `json:"state"`
Requests []any `json:"requests"`
AttemptNumber int `json:"attemptNumber"` // Current attempt number (1-based)
// AttemptIndex is a backward-compatibility alias for AttemptNumber
AttemptIndex int `json:"attemptIndex"`
MaxAttempts int `json:"maxAttempts"` // Maximum number of attempts for this stub
// TotalAttempts is a backward-compatibility alias for MaxAttempts
TotalAttempts int `json:"totalAttempts"`
StubID string `json:"stubId"` // Unique identifier of the stub
// RequestID is a backward-compatibility alias mapped to StubID
RequestID string `json:"requestId"`
}
Data represents the context data available for template rendering.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine provides template rendering functionality.
func (*Engine) ProcessError ¶
ProcessError processes error template.
func (*Engine) ProcessHeaders ¶
ProcessHeaders processes templates in headers.
func (*Engine) ProcessMap ¶
ProcessMap processes templates in a map recursively.
Click to show internal directories.
Click to hide internal directories.