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) 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
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. The key is created by normalizing the URL to include only the path and user input patterns, allowing different requests with the same pattern structure to share stored values.
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 with session integration.
func NewPrompter ¶
func NewPrompter(session *session.SessionManager, forcePrompt bool, useColors bool) *Prompter
NewPrompter creates a new prompter with session integration. If forcePrompt is true, the user will always be prompted even if values exist in session.
func (*Prompter) GenerateKey ¶
GenerateKey creates a session storage key from a URL pattern.
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.
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.