Documentation
¶
Overview ¶
Package userinput handles detection and processing of user input variables in HTTP request URLs using the {{:paramName}} syntax.
Index ¶
- type Detector
- func (d *Detector) Detect(content string) []Pattern
- func (d *Detector) ExtractPatternNames(url string) []string
- func (d *Detector) FindAll(content string) []Pattern
- func (d *Detector) GenerateKey(urlStr string) string
- func (d *Detector) GenerateRequestKey(method, urlStr string) string
- func (d *Detector) HasPatterns(content string) bool
- func (d *Detector) Replace(content string, values map[string]string) string
- func (d *Detector) ReplaceRaw(content string, values map[string]string) string
- type Pattern
- type ProcessResult
- type Prompter
- func (p *Prompter) GenerateKey(url string) string
- func (p *Prompter) HasPatterns(url string) bool
- func (p *Prompter) ProcessContent(content string, urlKey string) (string, error)
- func (p *Prompter) ProcessURL(url string) (*ProcessResult, error)
- func (p *Prompter) SetSecrets(secrets map[string]bool)
- func (p *Prompter) SetValues(values map[string]string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Detector ¶
type Detector struct{}
Detector detects {{:paramName}} patterns in URLs.
func NewDetector ¶
func NewDetector() *Detector
NewDetector creates a new user input pattern detector.
func (*Detector) Detect ¶
Detect finds all {{:paramName}} patterns in content and returns first occurrences per name ordered by appearance. If any occurrence of a parameter is marked !secret, the result inherits it.
func (*Detector) ExtractPatternNames ¶
ExtractPatternNames returns a list of unique parameter names from a URL.
func (*Detector) FindAll ¶ added in v0.2.18
FindAll returns every {{:paramName}} match in the given content in scanning order (including duplicates).
func (*Detector) GenerateKey ¶
GenerateKey creates a session storage key from a URL pattern (host + path + query). Use Detector.GenerateRequestKey to include additional context like HTTP method.
func (*Detector) GenerateRequestKey ¶ added in v0.2.20
GenerateRequestKey extends GenerateKey by prefixing the HTTP method when provided.
func (*Detector) HasPatterns ¶
HasPatterns checks if the content contains any user input patterns.
type Pattern ¶
type Pattern struct {
Name string // Canonical parameter name (e.g., "id")
Original string // Original matched pattern (e.g., "{{:id!secret}}")
Position int // Position in content
IsSecret bool // Whether the pattern uses the !secret suffix
}
Pattern represents a detected user input pattern in a URL.
type ProcessResult ¶
type ProcessResult struct {
URL string // The processed URL with patterns replaced
Values map[string]string // The values used for replacement (in order of appearance)
Patterns []Pattern // The patterns that were found (preserves order)
Prompted bool // Whether the user was prompted for values
Secrets map[string]bool // Which parameters are marked as secrets
}
ProcessResult contains the result of processing user input patterns.
type Prompter ¶
type Prompter struct {
// contains filtered or unexported fields
}
Prompter handles prompting users for input values. Values are collected during a single request execution and not persisted.
func NewPrompter ¶
NewPrompter creates a new prompter. The forcePrompt parameter is kept for API compatibility but is ignored since prompts always happen now (no session persistence).
func (*Prompter) GenerateKey ¶
GenerateKey creates a session storage key from a URL pattern. This method is kept for API compatibility but the key is not used for persistence.
func (*Prompter) HasPatterns ¶
HasPatterns checks if the URL contains any user input patterns.
func (*Prompter) ProcessContent ¶
ProcessContent processes user input patterns in any content string. This can be used for headers, body, or other content. The urlKey parameter is kept for API compatibility but is ignored.
func (*Prompter) ProcessURL ¶
func (p *Prompter) ProcessURL(url string) (*ProcessResult, error)
ProcessURL detects patterns, prompts if needed, and returns processed URL. Returns a ProcessResult containing the URL with all {{:paramName}} patterns replaced, the values used, and whether the user was prompted. If the user cancels the prompt, returns an error.
func (*Prompter) SetSecrets ¶ added in v0.2.20
SetSecrets marks specific parameters as secrets.