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(url string) []Pattern
- func (d *Detector) ExtractPatternNames(url string) []string
- func (d *Detector) GenerateKey(urlStr string) string
- func (d *Detector) HasPatterns(url string) bool
- func (d *Detector) Replace(urlStr string, values map[string]string) string
- func (d *Detector) ReplaceRaw(urlStr 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 a URL. Returns patterns in order of appearance, with duplicates removed. If the same parameter name appears multiple times, only the first occurrence is returned.
func (*Detector) ExtractPatternNames ¶
ExtractPatternNames returns a list of unique parameter names from a URL.
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 URL contains any user input patterns.
type Pattern ¶
type Pattern struct {
Name string // Parameter name (e.g., "id")
Original string // Original pattern (e.g., "{{:id}}")
Position int // Position in URL
}
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
}
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.