variables

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package variables provides variable resolution and substitution for HTTP request templates, supporting environment variables, system functions, file variables, and user prompts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateGUID

func GenerateGUID() string

GenerateGUID generates a new UUID

func ParseFileVariables

func ParseFileVariables(content string) map[string]string

ParseFileVariables parses file variables from content

Types

type DuplicateVariable added in v0.2.10

type DuplicateVariable struct {
	Name     string
	OldValue string
	NewValue string
}

DuplicateVariable holds information about a duplicate variable

type ParseFileVariablesResult added in v0.2.10

type ParseFileVariablesResult struct {
	Variables  map[string]string
	Duplicates []DuplicateVariable
}

ParseFileVariablesResult contains parsed variables and any duplicates found

func ParseFileVariablesWithDuplicates added in v0.2.10

func ParseFileVariablesWithDuplicates(content string) *ParseFileVariablesResult

ParseFileVariablesWithDuplicates parses file variables and returns duplicate information

type RequestResult

type RequestResult struct {
	StatusCode int
	Headers    map[string][]string
	Body       string
}

RequestResult holds the result of a named request for request variables

type Variable

type Variable struct {
	Name    string
	Value   string
	Type    VariableType
	Error   string
	Warning string
}

Variable represents a resolved variable

type VariableProcessor

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

VariableProcessor processes variables in request content

func NewVariableProcessor

func NewVariableProcessor() *VariableProcessor

NewVariableProcessor creates a new variable processor

func (*VariableProcessor) Process

func (v *VariableProcessor) Process(text string) (string, error)

Process processes all variables in the given text

func (*VariableProcessor) SetCurrentDir

func (v *VariableProcessor) SetCurrentDir(dir string)

SetCurrentDir sets the current directory for dotenv resolution

func (*VariableProcessor) SetEnvironment

func (v *VariableProcessor) SetEnvironment(env string)

SetEnvironment sets the current environment

func (*VariableProcessor) SetEnvironmentVariables

func (v *VariableProcessor) SetEnvironmentVariables(vars map[string]map[string]string)

SetEnvironmentVariables sets environment variables from config

func (*VariableProcessor) SetFileVariables

func (v *VariableProcessor) SetFileVariables(vars map[string]string)

SetFileVariables merges file variables into existing ones

func (*VariableProcessor) SetPromptHandler

func (v *VariableProcessor) SetPromptHandler(handler func(name, description string, isPassword bool) (string, error))

SetPromptHandler sets the handler for prompt variables

func (*VariableProcessor) SetRequestResult

func (v *VariableProcessor) SetRequestResult(name string, result RequestResult)

SetRequestResult stores a request result for request variables

type VariableType

type VariableType int

VariableType represents the type of variable

const (
	VariableTypeSystem VariableType = iota
	VariableTypeEnvironment
	VariableTypeFile
	VariableTypeRequest
	VariableTypePrompt
)

Jump to

Keyboard shortcuts

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