Documentation
¶
Index ¶
- Constants
- Variables
- func CleanupTempFile(info *TempFileInfo) error
- func FindUnresolvedVariables(text string, env *EnvironmentFile) []string
- func FindVariables(text string) []string
- func GenerateCurlCommand(req *CollectionRequest) string
- func GenerateCurlCommandWithOptions(req *CollectionRequest, opts CurlGeneratorOptions) string
- func GenerateCurlFromRequest(req *Request) string
- func GenerateID() string
- func GetExtensionForContentType(ct ContentType) string
- func GetSystemVariable(name string) string
- func HasContentChanged(info *TempFileInfo) (bool, error)
- func HeadersToText(headers map[string]string) string
- func PreviewVariableReplacement(text string, env *EnvironmentFile) string
- func ReadTempFile(info *TempFileInfo) (string, error)
- func ReplaceVariables(text string, env *EnvironmentFile) string
- func SaveCollection(collection *CollectionFile, path string) error
- func SaveEnvironment(env *EnvironmentFile, path string) error
- func TextToHeaders(text string) map[string]string
- func ValidateCollection(collection *CollectionFile) error
- func ValidateCurlCommand(cmd string) error
- func ValidateEnvironment(env *EnvironmentFile) error
- func ValidateHeaderText(text string) []string
- func ValidateVariables(req *Request, env *EnvironmentFile) []string
- type AssertionCollector
- func (c *AssertionCollector) AllPassed() bool
- func (c *AssertionCollector) Clear()
- func (c *AssertionCollector) FailureCount() int
- func (c *AssertionCollector) GetResults() []AssertionResult
- func (c *AssertionCollector) RegisterTest(name string, passed bool, expected, actual interface{}, message string)
- type AssertionResult
- type AuthConfig
- type BasicAuthCreds
- type BodyConfig
- type Client
- type Collection
- type CollectionFile
- func (c *CollectionFile) AddRequest(req *CollectionRequest)
- func (c *CollectionFile) AddRequestToFolder(folderPath []string, req *CollectionRequest) error
- func (c *CollectionFile) CopyFolderToFolder(sourcePath []string, sourceName string, targetFolderPath []string) *Folder
- func (c *CollectionFile) CopyRequestToFolder(requestID string, targetFolderPath []string) *CollectionRequest
- func (c *CollectionFile) CreateFolder(name string)
- func (c *CollectionFile) CreateFolderInPath(folderPath []string, name string) error
- func (c *CollectionFile) DeleteFolder(folderPath []string, name string) bool
- func (c *CollectionFile) DeleteRequest(id string) bool
- func (c *CollectionFile) DuplicateFolder(folderPath []string, name string) *Folder
- func (c *CollectionFile) DuplicateRequest(id string) *CollectionRequest
- func (c *CollectionFile) FindFolderByName(folderPath []string, name string) *Folder
- func (c *CollectionFile) FindRequest(id string) *CollectionRequest
- func (c *CollectionFile) RenameFolder(folderPath []string, oldName, newName string) bool
- func (c *CollectionFile) RenameRequest(id, newName string) bool
- func (c *CollectionFile) Save() error
- func (c *CollectionFile) UpdateRequest(id, newName string, method HTTPMethod, url string) bool
- func (c *CollectionFile) UpdateRequestAuth(id string, auth *AuthConfig) bool
- func (c *CollectionFile) UpdateRequestBody(id, bodyType, content string) bool
- func (c *CollectionFile) UpdateRequestScripts(id, preRequest, postRequest string) bool
- func (c *CollectionFile) UpdateRequestURL(id, url string) bool
- type CollectionRequest
- type ConsoleEntry
- func (e *ConsoleEntry) CopyAll() string
- func (e *ConsoleEntry) CopyBody() string
- func (e *ConsoleEntry) CopyCookies() string
- func (e *ConsoleEntry) CopyError() string
- func (e *ConsoleEntry) CopyHeaders() string
- func (e *ConsoleEntry) CopyInfo() string
- func (e *ConsoleEntry) FormatDuration() string
- func (e *ConsoleEntry) FormatSize() string
- func (e *ConsoleEntry) FormatTimestamp() string
- func (e *ConsoleEntry) GetStatusCode() int
- func (e *ConsoleEntry) HasError() bool
- func (e *ConsoleEntry) IsSuccess() bool
- type ConsoleEntryStatus
- type ConsoleHistory
- func (h *ConsoleHistory) Add(entry ConsoleEntry) string
- func (h *ConsoleHistory) Clear()
- func (h *ConsoleHistory) Get(id string) (*ConsoleEntry, bool)
- func (h *ConsoleHistory) GetAll() []ConsoleEntry
- func (h *ConsoleHistory) GetByIndex(idx int) (*ConsoleEntry, bool)
- func (h *ConsoleHistory) GetReversed() []ConsoleEntry
- func (h *ConsoleHistory) IsEmpty() bool
- func (h *ConsoleHistory) Len() int
- type ConsoleLogEntry
- type ConsoleLogLevel
- type ContentType
- type CurlGeneratorOptions
- type EditableField
- type EditorConfig
- type EditorSource
- type EnvChange
- type EnvChangeType
- type Environment
- type EnvironmentFile
- func (e *EnvironmentFile) Clone() *EnvironmentFile
- func (e *EnvironmentFile) DeleteVariable(name string)
- func (e *EnvironmentFile) GetVariable(name string) (string, bool)
- func (e *EnvironmentFile) GetVariableNames() []string
- func (e *EnvironmentFile) GetVariableRaw(name string) (*EnvironmentVariable, bool)
- func (e *EnvironmentFile) HasVariable(name string) bool
- func (e *EnvironmentFile) SetVariable(name, value string)
- func (e *EnvironmentFile) SetVariableFull(name string, v *EnvironmentVariable)
- func (e *EnvironmentFile) ToggleVariableActive(name string) bool
- func (e *EnvironmentFile) ToggleVariableSecret(name string) bool
- type EnvironmentVariable
- type Folder
- type FolderPreview
- type HTTPMethod
- type HeaderEntry
- type HeaderList
- type ImportError
- type ImportErrorType
- type ImportOptions
- type ImportPreview
- type KeyValueEntry
- type OpenAPIImporter
- func (i *OpenAPIImporter) BuildV3Model() (*libopenapi.DocumentModel[v3.Document], error)
- func (i *OpenAPIImporter) GetSpecInfo() (title, description string)
- func (i *OpenAPIImporter) GetVersion() string
- func (i *OpenAPIImporter) Preview() (*ImportPreview, error)
- func (i *OpenAPIImporter) ToCollection(opts ImportOptions) (*CollectionFile, error)
- func (i *OpenAPIImporter) ValidateVersion() error
- type ParseError
- type ParsedCurlCommand
- type Request
- type Response
- type ScriptConfig
- type ScriptConsole
- func (c *ScriptConsole) Clear()
- func (c *ScriptConsole) Debug(args ...interface{})
- func (c *ScriptConsole) Error(args ...interface{})
- func (c *ScriptConsole) GetEntries() []ConsoleLogEntry
- func (c *ScriptConsole) Info(args ...interface{})
- func (c *ScriptConsole) Log(args ...interface{})
- func (c *ScriptConsole) Warn(args ...interface{})
- type ScriptCookieJar
- func (j *ScriptCookieJar) Clear()
- func (j *ScriptCookieJar) Delete(name string)
- func (j *ScriptCookieJar) Get(name string) *http.Cookie
- func (j *ScriptCookieJar) GetAll() []*http.Cookie
- func (j *ScriptCookieJar) ParseSetCookieHeaders(headers map[string][]string)
- func (j *ScriptCookieJar) Set(cookie *http.Cookie)
- func (j *ScriptCookieJar) ToRequestHeader() string
- type ScriptEnvironment
- func (e *ScriptEnvironment) ApplyChanges() error
- func (e *ScriptEnvironment) Get(name string) string
- func (e *ScriptEnvironment) GetChanges() []EnvChange
- func (e *ScriptEnvironment) Has(name string) bool
- func (e *ScriptEnvironment) Set(name, value string)
- func (e *ScriptEnvironment) Unset(name string)
- type ScriptErrorInfo
- type ScriptExecutionError
- type ScriptExecutor
- type ScriptGlobals
- type ScriptInfo
- type ScriptRequest
- func (r *ScriptRequest) ApplyTo(req *CollectionRequest)
- func (r *ScriptRequest) Body() string
- func (r *ScriptRequest) GetHeader(name string) string
- func (r *ScriptRequest) Headers() map[string]string
- func (r *ScriptRequest) IsBodyModified() bool
- func (r *ScriptRequest) IsModified() bool
- func (r *ScriptRequest) Method() string
- func (r *ScriptRequest) Name() string
- func (r *ScriptRequest) RemoveHeader(name string)
- func (r *ScriptRequest) SetBody(body string)
- func (r *ScriptRequest) SetHeader(name, value string)
- func (r *ScriptRequest) SetURL(url string)
- func (r *ScriptRequest) URL() string
- type ScriptResponse
- type ScriptResult
- type ScriptSyntaxError
- type ScriptTimeoutError
- type TempFileInfo
- type Test
- type Token
- type TokenType
Constants ¶
const ( SystemVarTimestamp = "$timestamp" SystemVarDatetime = "$datetime" SystemVarDate = "$date" SystemVarTime = "$time" SystemVarRandomInt = "$randomInt" SystemVarRandomUUID = "$uuid" SystemVarGUID = "$guid" SystemVarRandom = "$random" )
System variable prefixes
Variables ¶
var ContentTypeExtensions = map[ContentType]string{ ContentTypeJSON: ".json", ContentTypeXML: ".xml", ContentTypeHTML: ".html", ContentTypeText: ".txt", }
ContentTypeExtensions maps content types to file extensions
var ErrEditorNotFound = errors.New("editor not found in PATH")
ErrEditorNotFound is returned when the configured editor binary doesn't exist
var ErrNoEditorAvailable = errors.New("no editor available: set $EDITOR or $VISUAL environment variable")
ErrNoEditorAvailable is returned when no editor can be found
Functions ¶
func CleanupTempFile ¶ added in v1.2.0
func CleanupTempFile(info *TempFileInfo) error
CleanupTempFile removes the temporary file. Safe to call multiple times; ignores "file not found" errors. Safe to call with nil info (no-op).
func FindUnresolvedVariables ¶
func FindUnresolvedVariables(text string, env *EnvironmentFile) []string
FindUnresolvedVariables finds variables that couldn't be resolved in the environment
func FindVariables ¶
FindVariables finds all variable references in a string
func GenerateCurlCommand ¶ added in v1.1.0
func GenerateCurlCommand(req *CollectionRequest) string
GenerateCurlCommand generates a valid cURL command from a CollectionRequest
func GenerateCurlCommandWithOptions ¶ added in v1.1.0
func GenerateCurlCommandWithOptions(req *CollectionRequest, opts CurlGeneratorOptions) string
GenerateCurlCommandWithOptions generates a cURL command with custom formatting
func GenerateCurlFromRequest ¶ added in v1.1.0
GenerateCurlFromRequest generates a cURL command from a Request (simpler type)
func GetExtensionForContentType ¶ added in v1.2.0
func GetExtensionForContentType(ct ContentType) string
GetExtensionForContentType returns the file extension (with leading dot) for the given content type.
func GetSystemVariable ¶
GetSystemVariable returns the value of a system variable Exported for use by preview mode in editor
func HasContentChanged ¶ added in v1.2.0
func HasContentChanged(info *TempFileInfo) (bool, error)
HasContentChanged compares original content with current file content. Returns true if content has been modified. Returns error if info is nil.
func HeadersToText ¶ added in v1.2.0
HeadersToText converts a headers map to text format. Each header is formatted as "Key: Value" on its own line. Headers are sorted alphabetically by key for consistency.
func PreviewVariableReplacement ¶
func PreviewVariableReplacement(text string, env *EnvironmentFile) string
PreviewVariableReplacement shows what the text would look like after variable replacement
func ReadTempFile ¶ added in v1.2.0
func ReadTempFile(info *TempFileInfo) (string, error)
ReadTempFile reads the current content of a temp file.
Returns the content as string, or error if file is unreadable. Returns error if info is nil.
func ReplaceVariables ¶
func ReplaceVariables(text string, env *EnvironmentFile) string
ReplaceVariables replaces all variables in a string with their values from the environment
func SaveCollection ¶
func SaveCollection(collection *CollectionFile, path string) error
SaveCollection saves a collection to a JSON file
func SaveEnvironment ¶
func SaveEnvironment(env *EnvironmentFile, path string) error
SaveEnvironment saves an environment to a JSON file
func TextToHeaders ¶ added in v1.2.0
TextToHeaders parses text format back to headers map. Lines without ": " separator are ignored. Whitespace is trimmed from keys and values.
func ValidateCollection ¶
func ValidateCollection(collection *CollectionFile) error
ValidateCollection validates a collection structure
func ValidateCurlCommand ¶ added in v1.1.0
ValidateCurlCommand performs quick validation of a cURL command
func ValidateEnvironment ¶
func ValidateEnvironment(env *EnvironmentFile) error
ValidateEnvironment validates an environment structure
func ValidateHeaderText ¶ added in v1.2.0
ValidateHeaderText checks if text is valid header format. Returns list of warnings for lines that couldn't be parsed.
func ValidateVariables ¶
func ValidateVariables(req *Request, env *EnvironmentFile) []string
ValidateVariables checks if all variables in a request can be resolved
Types ¶
type AssertionCollector ¶ added in v1.3.0
type AssertionCollector struct {
// contains filtered or unexported fields
}
AssertionCollector gathers test results during script execution
func NewAssertionCollector ¶ added in v1.3.0
func NewAssertionCollector() *AssertionCollector
NewAssertionCollector creates a new collector
func (*AssertionCollector) AllPassed ¶ added in v1.3.0
func (c *AssertionCollector) AllPassed() bool
AllPassed returns true if all assertions passed
func (*AssertionCollector) Clear ¶ added in v1.3.0
func (c *AssertionCollector) Clear()
Clear removes all results
func (*AssertionCollector) FailureCount ¶ added in v1.3.0
func (c *AssertionCollector) FailureCount() int
FailureCount returns the number of failed assertions
func (*AssertionCollector) GetResults ¶ added in v1.3.0
func (c *AssertionCollector) GetResults() []AssertionResult
GetResults returns all assertion results
func (*AssertionCollector) RegisterTest ¶ added in v1.3.0
func (c *AssertionCollector) RegisterTest(name string, passed bool, expected, actual interface{}, message string)
RegisterTest adds a test result to the collector
type AssertionResult ¶ added in v1.3.0
type AssertionResult struct {
Name string `json:"name"`
Passed bool `json:"passed"`
Expected interface{} `json:"expected,omitempty"`
Actual interface{} `json:"actual,omitempty"`
Message string `json:"message,omitempty"`
}
AssertionResult represents the outcome of a test assertion
type AuthConfig ¶
type AuthConfig struct {
Type string `json:"type"` // "none", "bearer", "basic", "api_key"
Token string `json:"token,omitempty"` // For bearer token
Prefix string `json:"prefix,omitempty"` // For bearer prefix (default: "Bearer")
// Basic auth
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
// API Key
APIKeyName string `json:"api_key_name,omitempty"`
APIKeyValue string `json:"api_key_value,omitempty"`
APIKeyLocation string `json:"api_key_location,omitempty"` // "header" or "query"
}
AuthConfig represents authentication configuration
type BasicAuthCreds ¶ added in v1.1.0
BasicAuthCreds holds parsed basic auth credentials
type BodyConfig ¶
type BodyConfig struct {
Type string `json:"type"` // "none", "json", "form-data", "raw", "binary"
Content interface{} `json:"content,omitempty"` // JSON object, string, or form data
}
BodyConfig represents request body configuration
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles HTTP requests
type Collection ¶
Collection represents a collection of requests
type CollectionFile ¶
type CollectionFile struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Folders []Folder `json:"folders,omitempty"`
Requests []CollectionRequest `json:"requests,omitempty"`
FilePath string `json:"-"` // Path to the file (not serialized)
}
CollectionFile represents a collection file structure
func LoadAllCollections ¶
func LoadAllCollections(dir string) ([]*CollectionFile, error)
LoadAllCollections loads all collections from a directory
func LoadCollection ¶
func LoadCollection(path string) (*CollectionFile, error)
LoadCollection loads a collection from a JSON file
func (*CollectionFile) AddRequest ¶
func (c *CollectionFile) AddRequest(req *CollectionRequest)
AddRequest adds a request to the collection
func (*CollectionFile) AddRequestToFolder ¶
func (c *CollectionFile) AddRequestToFolder(folderPath []string, req *CollectionRequest) error
AddRequestToFolder adds a request to a specific folder
func (*CollectionFile) CopyFolderToFolder ¶
func (c *CollectionFile) CopyFolderToFolder(sourcePath []string, sourceName string, targetFolderPath []string) *Folder
CopyFolderToFolder copies a folder to a target location
func (*CollectionFile) CopyRequestToFolder ¶
func (c *CollectionFile) CopyRequestToFolder(requestID string, targetFolderPath []string) *CollectionRequest
CopyRequestToFolder copies a request to a target folder
func (*CollectionFile) CreateFolder ¶
func (c *CollectionFile) CreateFolder(name string)
CreateFolder creates a new folder in the collection
func (*CollectionFile) CreateFolderInPath ¶
func (c *CollectionFile) CreateFolderInPath(folderPath []string, name string) error
CreateFolderInPath creates a folder at the specified path
func (*CollectionFile) DeleteFolder ¶
func (c *CollectionFile) DeleteFolder(folderPath []string, name string) bool
DeleteFolder removes a folder by name from the specified path
func (*CollectionFile) DeleteRequest ¶
func (c *CollectionFile) DeleteRequest(id string) bool
DeleteRequest removes a request by ID from anywhere in the collection
func (*CollectionFile) DuplicateFolder ¶
func (c *CollectionFile) DuplicateFolder(folderPath []string, name string) *Folder
DuplicateFolder duplicates a folder by name at the specified path
func (*CollectionFile) DuplicateRequest ¶
func (c *CollectionFile) DuplicateRequest(id string) *CollectionRequest
DuplicateRequest duplicates a request by ID
func (*CollectionFile) FindFolderByName ¶
func (c *CollectionFile) FindFolderByName(folderPath []string, name string) *Folder
FindFolder finds a folder by name in the collection
func (*CollectionFile) FindRequest ¶
func (c *CollectionFile) FindRequest(id string) *CollectionRequest
FindRequest searches for a request by ID in the collection
func (*CollectionFile) RenameFolder ¶
func (c *CollectionFile) RenameFolder(folderPath []string, oldName, newName string) bool
RenameFolder renames a folder at the specified path
func (*CollectionFile) RenameRequest ¶
func (c *CollectionFile) RenameRequest(id, newName string) bool
RenameRequest renames a request by ID
func (*CollectionFile) Save ¶
func (c *CollectionFile) Save() error
Save saves the collection to its file path
func (*CollectionFile) UpdateRequest ¶
func (c *CollectionFile) UpdateRequest(id, newName string, method HTTPMethod, url string) bool
UpdateRequest updates a request's name, method, and URL by ID
func (*CollectionFile) UpdateRequestAuth ¶
func (c *CollectionFile) UpdateRequestAuth(id string, auth *AuthConfig) bool
UpdateRequestAuth updates the auth configuration of a request by ID
func (*CollectionFile) UpdateRequestBody ¶
func (c *CollectionFile) UpdateRequestBody(id, bodyType, content string) bool
UpdateRequestBody updates the body of a request by ID
func (*CollectionFile) UpdateRequestScripts ¶
func (c *CollectionFile) UpdateRequestScripts(id, preRequest, postRequest string) bool
UpdateRequestScripts updates the scripts of a request by ID
func (*CollectionFile) UpdateRequestURL ¶
func (c *CollectionFile) UpdateRequestURL(id, url string) bool
UpdateRequestURL updates only the URL of a request by ID
type CollectionRequest ¶
type CollectionRequest struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Method HTTPMethod `json:"method"`
URL string `json:"url"`
Params []KeyValueEntry `json:"params,omitempty"` // Query parameters
Headers []KeyValueEntry `json:"headers,omitempty"` // Request headers (new format)
HeadersMap map[string]string `json:"headers_map,omitempty"` // Legacy headers format
Auth *AuthConfig `json:"auth,omitempty"` // Authentication config
Body *BodyConfig `json:"body,omitempty"` // Request body config
Scripts *ScriptConfig `json:"scripts,omitempty"` // Pre/post scripts
Tests []Test `json:"tests,omitempty"`
}
CollectionRequest represents a saved request in a collection
func FromRequest ¶
func FromRequest(req *Request, name string) *CollectionRequest
FromRequest creates a CollectionRequest from a Request
func ParseCurlCommand ¶ added in v1.1.0
func ParseCurlCommand(cmd string) (*CollectionRequest, error)
ParseCurlCommand parses a cURL command string into a CollectionRequest
func (*CollectionRequest) ToRequest ¶
func (cr *CollectionRequest) ToRequest() *Request
ToRequest converts a CollectionRequest to a Request
func (*CollectionRequest) UnmarshalJSON ¶
func (cr *CollectionRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom unmarshaling to handle both old (map) and new (array) header/param formats
type ConsoleEntry ¶
type ConsoleEntry struct {
ID string
Timestamp time.Time
Request *Request
Response *Response
Error error
Duration time.Duration
Status ConsoleEntryStatus
}
ConsoleEntry represents a single request/response pair in the console
func NewConsoleEntry ¶
NewConsoleEntry creates a new console entry from a completed request
func (*ConsoleEntry) CopyAll ¶
func (e *ConsoleEntry) CopyAll() string
CopyAll returns complete request/response for clipboard
func (*ConsoleEntry) CopyBody ¶
func (e *ConsoleEntry) CopyBody() string
CopyBody returns response body for clipboard
func (*ConsoleEntry) CopyCookies ¶
func (e *ConsoleEntry) CopyCookies() string
CopyCookies returns cookies from response headers for clipboard
func (*ConsoleEntry) CopyError ¶
func (e *ConsoleEntry) CopyError() string
CopyError returns formatted error message for clipboard
func (*ConsoleEntry) CopyHeaders ¶
func (e *ConsoleEntry) CopyHeaders() string
CopyHeaders returns formatted headers string for clipboard
func (*ConsoleEntry) CopyInfo ¶
func (e *ConsoleEntry) CopyInfo() string
CopyInfo returns request/response summary info for clipboard
func (*ConsoleEntry) FormatDuration ¶
func (e *ConsoleEntry) FormatDuration() string
FormatDuration returns human-readable duration (e.g., "125ms", "1.2s")
func (*ConsoleEntry) FormatSize ¶
func (e *ConsoleEntry) FormatSize() string
FormatSize returns human-readable response size (e.g., "2.4KB", "1.2MB")
func (*ConsoleEntry) FormatTimestamp ¶
func (e *ConsoleEntry) FormatTimestamp() string
FormatTimestamp returns timestamp in HH:MM:SS format
func (*ConsoleEntry) GetStatusCode ¶
func (e *ConsoleEntry) GetStatusCode() int
GetStatusCode returns the HTTP status code, or 0 if error
func (*ConsoleEntry) HasError ¶
func (e *ConsoleEntry) HasError() bool
HasError returns true if the entry represents a failed request
func (*ConsoleEntry) IsSuccess ¶
func (e *ConsoleEntry) IsSuccess() bool
IsSuccess returns true if response is 2xx
type ConsoleEntryStatus ¶
type ConsoleEntryStatus int
ConsoleEntryStatus represents the visual status of a console entry
const ( StatusSuccess ConsoleEntryStatus = iota // 2xx StatusRedirect // 3xx StatusClientError // 4xx StatusServerError // 5xx StatusNetworkError // Connection failures )
type ConsoleHistory ¶
type ConsoleHistory struct {
// contains filtered or unexported fields
}
ConsoleHistory manages a collection of console entries with thread-safe access
func NewConsoleHistory ¶
func NewConsoleHistory(maxSize int) *ConsoleHistory
NewConsoleHistory creates a new history manager
func (*ConsoleHistory) Add ¶
func (h *ConsoleHistory) Add(entry ConsoleEntry) string
Add appends a new entry to history (thread-safe)
func (*ConsoleHistory) Clear ¶
func (h *ConsoleHistory) Clear()
Clear removes all entries (thread-safe)
func (*ConsoleHistory) Get ¶
func (h *ConsoleHistory) Get(id string) (*ConsoleEntry, bool)
Get retrieves an entry by ID (thread-safe)
func (*ConsoleHistory) GetAll ¶
func (h *ConsoleHistory) GetAll() []ConsoleEntry
GetAll returns all entries in chronological order (oldest first, thread-safe)
func (*ConsoleHistory) GetByIndex ¶
func (h *ConsoleHistory) GetByIndex(idx int) (*ConsoleEntry, bool)
GetByIndex returns entry at display index (0 = newest, thread-safe)
func (*ConsoleHistory) GetReversed ¶
func (h *ConsoleHistory) GetReversed() []ConsoleEntry
GetReversed returns entries in reverse chronological order (newest first, thread-safe)
func (*ConsoleHistory) IsEmpty ¶
func (h *ConsoleHistory) IsEmpty() bool
IsEmpty returns true if no entries (thread-safe)
func (*ConsoleHistory) Len ¶
func (h *ConsoleHistory) Len() int
Len returns the number of entries (thread-safe)
type ConsoleLogEntry ¶ added in v1.3.0
type ConsoleLogEntry struct {
Level ConsoleLogLevel `json:"level"`
Message string `json:"message"`
Timestamp time.Time `json:"timestamp"`
}
ConsoleLogEntry represents a single console output
type ConsoleLogLevel ¶ added in v1.3.0
type ConsoleLogLevel string
ConsoleLogLevel represents log severity
const ( LogLevelLog ConsoleLogLevel = "log" LogLevelInfo ConsoleLogLevel = "info" LogLevelWarn ConsoleLogLevel = "warn" LogLevelError ConsoleLogLevel = "error" LogLevelDebug ConsoleLogLevel = "debug" )
type ContentType ¶ added in v1.2.0
type ContentType string
ContentType represents detected content format
const ( ContentTypeJSON ContentType = "json" ContentTypeXML ContentType = "xml" ContentTypeHTML ContentType = "html" ContentTypeText ContentType = "text" )
func DetectContentType ¶ added in v1.2.0
func DetectContentType(content string) ContentType
DetectContentType analyzes content and returns its type. Uses heuristics to detect JSON, XML, HTML, or plain text.
type CurlGeneratorOptions ¶ added in v1.1.0
type CurlGeneratorOptions struct {
Multiline bool // Use backslash continuation
IndentString string // Indentation for multiline (default: " ")
QuoteStyle string // "single" or "double" (default: "single")
IncludeMethod bool // Always include -X even for GET (default: false)
}
CurlGeneratorOptions configures output format
func DefaultGeneratorOptions ¶ added in v1.1.0
func DefaultGeneratorOptions() CurlGeneratorOptions
DefaultGeneratorOptions returns sensible defaults
type EditableField ¶ added in v1.2.0
type EditableField string
EditableField represents a field that can be edited externally
const ( EditableFieldBody EditableField = "body" EditableFieldHeaders EditableField = "headers" )
type EditorConfig ¶ added in v1.2.0
type EditorConfig struct {
// Binary is the path to the editor executable
Binary string
// Args are additional arguments to pass to the editor
// (e.g., ["--wait"] for VS Code)
Args []string
// Source indicates where the config came from
Source EditorSource
}
EditorConfig holds the parsed editor command configuration
func GetEditorConfig ¶ added in v1.2.0
func GetEditorConfig() (*EditorConfig, error)
GetEditorConfig returns the resolved editor configuration by checking $VISUAL, $EDITOR, and fallback editors.
Detection order: 1. $VISUAL environment variable 2. $EDITOR environment variable 3. Fallback: nano, vi (first available)
func (*EditorConfig) Validate ¶ added in v1.2.0
func (ec *EditorConfig) Validate() error
Validate checks if the editor binary exists and is executable
type EditorSource ¶ added in v1.2.0
type EditorSource string
EditorSource indicates the origin of editor configuration
const ( EditorSourceVisual EditorSource = "VISUAL" EditorSourceEditor EditorSource = "EDITOR" EditorSourceFallback EditorSource = "fallback" )
type EnvChange ¶ added in v1.3.0
type EnvChange struct {
Type EnvChangeType `json:"type"`
Name string `json:"name"`
Value string `json:"value,omitempty"` // Only for "set"
Previous string `json:"previous,omitempty"`
}
EnvChange represents a single environment variable modification
type EnvChangeType ¶ added in v1.3.0
type EnvChangeType string
EnvChangeType represents the type of environment change
const ( EnvChangeSet EnvChangeType = "set" EnvChangeUnset EnvChangeType = "unset" )
type Environment ¶
Environment represents environment variables for requests
func EnvironmentFromFile ¶ added in v1.3.0
func EnvironmentFromFile(envFile *EnvironmentFile) *Environment
EnvironmentFromFile converts an EnvironmentFile to a simple Environment
type EnvironmentFile ¶
type EnvironmentFile struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Variables map[string]*EnvironmentVariable `json:"variables"`
FilePath string `json:"-"` // Internal: path to the file
}
EnvironmentFile represents an environment configuration file
func LoadAllEnvironments ¶
func LoadAllEnvironments(dir string) ([]*EnvironmentFile, error)
LoadAllEnvironments loads all environments from a directory
func LoadEnvironment ¶
func LoadEnvironment(path string) (*EnvironmentFile, error)
LoadEnvironment loads an environment from a JSON file Supports both new format (with EnvironmentVariable) and legacy format (simple string values)
func MergeEnvironments ¶
func MergeEnvironments(envs ...*EnvironmentFile) *EnvironmentFile
MergeEnvironments merges multiple environments, with later environments overriding earlier ones
func (*EnvironmentFile) Clone ¶
func (e *EnvironmentFile) Clone() *EnvironmentFile
Clone creates a deep copy of the environment
func (*EnvironmentFile) DeleteVariable ¶
func (e *EnvironmentFile) DeleteVariable(name string)
DeleteVariable removes a variable from the environment
func (*EnvironmentFile) GetVariable ¶
func (e *EnvironmentFile) GetVariable(name string) (string, bool)
GetVariable retrieves a variable value from the environment (only if active)
func (*EnvironmentFile) GetVariableNames ¶
func (e *EnvironmentFile) GetVariableNames() []string
GetVariableNames returns all variable names in the environment
func (*EnvironmentFile) GetVariableRaw ¶
func (e *EnvironmentFile) GetVariableRaw(name string) (*EnvironmentVariable, bool)
GetVariableRaw retrieves a variable regardless of active state
func (*EnvironmentFile) HasVariable ¶
func (e *EnvironmentFile) HasVariable(name string) bool
HasVariable checks if a variable exists in the environment
func (*EnvironmentFile) SetVariable ¶
func (e *EnvironmentFile) SetVariable(name, value string)
SetVariable sets a variable value in the environment
func (*EnvironmentFile) SetVariableFull ¶
func (e *EnvironmentFile) SetVariableFull(name string, v *EnvironmentVariable)
SetVariableFull sets a variable with all metadata
func (*EnvironmentFile) ToggleVariableActive ¶
func (e *EnvironmentFile) ToggleVariableActive(name string) bool
ToggleVariableActive toggles the active flag of a variable
func (*EnvironmentFile) ToggleVariableSecret ¶
func (e *EnvironmentFile) ToggleVariableSecret(name string) bool
ToggleVariableSecret toggles the secret flag of a variable
type EnvironmentVariable ¶
type EnvironmentVariable struct {
Value string `json:"value"`
Secret bool `json:"secret,omitempty"`
Active bool `json:"active"`
}
EnvironmentVariable represents a variable with metadata
type Folder ¶
type Folder struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Folders []Folder `json:"folders,omitempty"`
Requests []CollectionRequest `json:"requests,omitempty"`
}
Folder represents a folder in a collection
type FolderPreview ¶ added in v1.2.0
type FolderPreview struct {
// Name is the tag/folder name
Name string
// Description is the tag description
Description string
// RequestCount is the number of operations with this tag
RequestCount int
}
FolderPreview describes a folder to be created from a tag.
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod represents HTTP request methods
const ( GET HTTPMethod = "GET" POST HTTPMethod = "POST" PUT HTTPMethod = "PUT" PATCH HTTPMethod = "PATCH" DELETE HTTPMethod = "DELETE" HEAD HTTPMethod = "HEAD" OPTIONS HTTPMethod = "OPTIONS" )
type HeaderEntry ¶ added in v1.2.0
HeaderEntry represents a single HTTP header
type HeaderList ¶ added in v1.2.0
type HeaderList []HeaderEntry
HeaderList is an ordered list of headers
type ImportError ¶ added in v1.2.0
type ImportError struct {
// Type categorizes the error
Type ImportErrorType
// Message is the user-friendly error description
Message string
// Details provides technical details for debugging
Details string
// Line is the source line number (1-based, 0 if unavailable)
Line int
// Column is the source column number (1-based, 0 if unavailable)
Column int
// Cause is the underlying error
Cause error
}
ImportError is returned when import fails.
func (*ImportError) Error ¶ added in v1.2.0
func (e *ImportError) Error() string
Error implements the error interface.
func (*ImportError) Unwrap ¶ added in v1.2.0
func (e *ImportError) Unwrap() error
Unwrap returns the underlying error.
type ImportErrorType ¶ added in v1.2.0
type ImportErrorType int
ImportErrorType categorizes import errors.
const ( // ErrFileNotFound indicates the spec file does not exist ErrFileNotFound ImportErrorType = iota // ErrFileUnreadable indicates the file cannot be read ErrFileUnreadable // ErrInvalidFormat indicates the file is not valid JSON or YAML ErrInvalidFormat // ErrUnsupportedVersion indicates OpenAPI 2.0 or unknown version ErrUnsupportedVersion // ErrValidationFailed indicates the spec failed validation ErrValidationFailed // ErrRefResolutionFailed indicates a $ref could not be resolved ErrRefResolutionFailed // ErrConversionFailed indicates an error during collection building ErrConversionFailed )
func (ImportErrorType) String ¶ added in v1.2.0
func (t ImportErrorType) String() string
String returns a string representation of the error type.
type ImportOptions ¶ added in v1.2.0
type ImportOptions struct {
// Name overrides the collection name (default: uses info.title)
Name string
// OutputPath specifies where to save the collection (default: .lazycurl/collections/<name>.json)
OutputPath string
// BaseURL overrides the server URL from the spec
BaseURL string
// IncludeExamples enables example generation for request bodies
IncludeExamples bool
// CreateEnvironment creates an environment with server variables
CreateEnvironment bool
}
ImportOptions configures the import behavior.
type ImportPreview ¶ added in v1.2.0
type ImportPreview struct {
// SpecVersion is the OpenAPI version (e.g., "3.0.3", "3.1.0")
SpecVersion string
// Title is the API title from info.title
Title string
// Description is the API description from info.description
Description string
// EndpointCount is the total number of operations
EndpointCount int
// FolderCount is the number of tags (folders to create)
FolderCount int
// Folders lists tag names and their operation counts
Folders []FolderPreview
// Servers lists available server URLs
Servers []string
// Warnings lists non-fatal issues encountered during parsing
Warnings []string
}
ImportPreview provides statistics about an import before execution.
type KeyValueEntry ¶
type KeyValueEntry struct {
Key string `json:"key"`
Value string `json:"value"`
Enabled bool `json:"enabled"`
}
KeyValueEntry represents a key-value pair with enabled state (for params, headers)
type OpenAPIImporter ¶ added in v1.2.0
type OpenAPIImporter struct {
// contains filtered or unexported fields
}
OpenAPIImporter handles OpenAPI spec parsing and conversion
func NewOpenAPIImporter ¶ added in v1.2.0
func NewOpenAPIImporter(data []byte) (*OpenAPIImporter, error)
NewOpenAPIImporter creates an importer from file data
func NewOpenAPIImporterFromFile ¶ added in v1.2.0
func NewOpenAPIImporterFromFile(filePath string) (*OpenAPIImporter, error)
NewOpenAPIImporterFromFile creates an importer from a file path
func (*OpenAPIImporter) BuildV3Model ¶ added in v1.2.0
func (i *OpenAPIImporter) BuildV3Model() (*libopenapi.DocumentModel[v3.Document], error)
BuildV3Model builds and caches the V3 model
func (*OpenAPIImporter) GetSpecInfo ¶ added in v1.2.0
func (i *OpenAPIImporter) GetSpecInfo() (title, description string)
GetSpecInfo returns the spec info (title, description)
func (*OpenAPIImporter) GetVersion ¶ added in v1.2.0
func (i *OpenAPIImporter) GetVersion() string
GetVersion returns the OpenAPI version (e.g., "3.0.3", "3.1.0")
func (*OpenAPIImporter) Preview ¶ added in v1.2.0
func (i *OpenAPIImporter) Preview() (*ImportPreview, error)
Preview returns import statistics without creating collection
func (*OpenAPIImporter) ToCollection ¶ added in v1.2.0
func (i *OpenAPIImporter) ToCollection(opts ImportOptions) (*CollectionFile, error)
ToCollection converts the spec to a LazyCurl collection
func (*OpenAPIImporter) ValidateVersion ¶ added in v1.2.0
func (i *OpenAPIImporter) ValidateVersion() error
ValidateVersion checks if the OpenAPI version is supported (3.0.x or 3.1.x)
type ParseError ¶ added in v1.1.0
ParseError provides context about parsing failures
func (*ParseError) Error ¶ added in v1.1.0
func (e *ParseError) Error() string
Error implements the error interface
func (*ParseError) FormatWithContext ¶ added in v1.1.0
func (e *ParseError) FormatWithContext() string
FormatWithContext returns a multi-line error message with visual indicator
type ParsedCurlCommand ¶ added in v1.1.0
type ParsedCurlCommand struct {
Method HTTPMethod
URL string
Headers []KeyValueEntry
Body string
BasicAuth *BasicAuthCreds
UserAgent string
Cookies []string
Insecure bool
RawFlags []string // Unrecognized flags
}
ParsedCurlCommand holds the result of parsing a cURL command
func (*ParsedCurlCommand) ToCollectionRequest ¶ added in v1.1.0
func (p *ParsedCurlCommand) ToCollectionRequest() *CollectionRequest
ToCollectionRequest converts ParsedCurlCommand to CollectionRequest
type Request ¶
type Request struct {
Method HTTPMethod
URL string
Headers map[string]string
Body interface{}
Timeout time.Duration
}
Request represents an HTTP request
func ReplaceVariablesInRequest ¶
func ReplaceVariablesInRequest(req *Request, env *EnvironmentFile) *Request
ReplaceVariablesInRequest replaces variables in all parts of a request
type Response ¶
type Response struct {
StatusCode int
Status string
Headers map[string][]string
Body string
Time time.Duration
Size int64
}
Response represents an HTTP response
type ScriptConfig ¶
type ScriptConfig struct {
PreRequest string `json:"pre_request,omitempty"`
PostRequest string `json:"post_request,omitempty"`
}
ScriptConfig represents pre/post request scripts
type ScriptConsole ¶ added in v1.3.0
type ScriptConsole struct {
// contains filtered or unexported fields
}
ScriptConsole collects console output from scripts
func NewScriptConsole ¶ added in v1.3.0
func NewScriptConsole() *ScriptConsole
NewScriptConsole creates a new console capture instance
func (*ScriptConsole) Clear ¶ added in v1.3.0
func (c *ScriptConsole) Clear()
Clear removes all logged entries
func (*ScriptConsole) Debug ¶ added in v1.3.0
func (c *ScriptConsole) Debug(args ...interface{})
Debug adds a debug level message
func (*ScriptConsole) Error ¶ added in v1.3.0
func (c *ScriptConsole) Error(args ...interface{})
Error adds an error level message
func (*ScriptConsole) GetEntries ¶ added in v1.3.0
func (c *ScriptConsole) GetEntries() []ConsoleLogEntry
GetEntries returns all logged entries
func (*ScriptConsole) Info ¶ added in v1.3.0
func (c *ScriptConsole) Info(args ...interface{})
Info adds an info level message
func (*ScriptConsole) Log ¶ added in v1.3.0
func (c *ScriptConsole) Log(args ...interface{})
Log adds a log level message
func (*ScriptConsole) Warn ¶ added in v1.3.0
func (c *ScriptConsole) Warn(args ...interface{})
Warn adds a warning level message
type ScriptCookieJar ¶ added in v1.3.0
type ScriptCookieJar struct {
// contains filtered or unexported fields
}
ScriptCookieJar manages cookies for script execution Cookies can be read from responses and set for future requests
func NewScriptCookieJar ¶ added in v1.3.0
func NewScriptCookieJar() *ScriptCookieJar
NewScriptCookieJar creates a new cookie jar for scripts
func (*ScriptCookieJar) Clear ¶ added in v1.3.0
func (j *ScriptCookieJar) Clear()
Clear removes all cookies
func (*ScriptCookieJar) Delete ¶ added in v1.3.0
func (j *ScriptCookieJar) Delete(name string)
Delete removes a cookie by name
func (*ScriptCookieJar) Get ¶ added in v1.3.0
func (j *ScriptCookieJar) Get(name string) *http.Cookie
Get retrieves a cookie by name
func (*ScriptCookieJar) GetAll ¶ added in v1.3.0
func (j *ScriptCookieJar) GetAll() []*http.Cookie
GetAll returns all cookies
func (*ScriptCookieJar) ParseSetCookieHeaders ¶ added in v1.3.0
func (j *ScriptCookieJar) ParseSetCookieHeaders(headers map[string][]string)
ParseSetCookieHeaders parses Set-Cookie headers from response and adds to jar
func (*ScriptCookieJar) Set ¶ added in v1.3.0
func (j *ScriptCookieJar) Set(cookie *http.Cookie)
Set adds or updates a cookie
func (*ScriptCookieJar) ToRequestHeader ¶ added in v1.3.0
func (j *ScriptCookieJar) ToRequestHeader() string
ToRequestHeader returns cookie string for request header
type ScriptEnvironment ¶ added in v1.3.0
type ScriptEnvironment struct {
// contains filtered or unexported fields
}
ScriptEnvironment wraps Environment for script access with change tracking
func NewScriptEnvironment ¶ added in v1.3.0
func NewScriptEnvironment(env *Environment) *ScriptEnvironment
NewScriptEnvironment wraps an environment for script use
func NewScriptEnvironmentFromFile ¶ added in v1.3.0
func NewScriptEnvironmentFromFile(envFile *EnvironmentFile) *ScriptEnvironment
NewScriptEnvironmentFromFile creates a ScriptEnvironment from an EnvironmentFile
func (*ScriptEnvironment) ApplyChanges ¶ added in v1.3.0
func (e *ScriptEnvironment) ApplyChanges() error
ApplyChanges persists the changes to the underlying environment
func (*ScriptEnvironment) Get ¶ added in v1.3.0
func (e *ScriptEnvironment) Get(name string) string
Get retrieves an environment variable value
func (*ScriptEnvironment) GetChanges ¶ added in v1.3.0
func (e *ScriptEnvironment) GetChanges() []EnvChange
GetChanges returns all environment variable modifications
func (*ScriptEnvironment) Has ¶ added in v1.3.0
func (e *ScriptEnvironment) Has(name string) bool
Has checks if an environment variable exists
func (*ScriptEnvironment) Set ¶ added in v1.3.0
func (e *ScriptEnvironment) Set(name, value string)
Set sets an environment variable value and tracks the change
func (*ScriptEnvironment) Unset ¶ added in v1.3.0
func (e *ScriptEnvironment) Unset(name string)
Unset removes an environment variable and tracks the change
type ScriptErrorInfo ¶ added in v1.3.0
type ScriptErrorInfo struct {
Type string `json:"type"`
Message string `json:"message"`
Line int `json:"line,omitempty"`
Column int `json:"column,omitempty"`
StackTrace string `json:"stack_trace,omitempty"`
}
ScriptErrorInfo contains detailed error information for display
type ScriptExecutionError ¶ added in v1.3.0
type ScriptExecutionError struct {
Message string
Line int
Column int
StackTrace string
Cause error
}
ScriptExecutionError wraps script runtime errors with location information
func (*ScriptExecutionError) Error ¶ added in v1.3.0
func (e *ScriptExecutionError) Error() string
Error implements the error interface
func (*ScriptExecutionError) Unwrap ¶ added in v1.3.0
func (e *ScriptExecutionError) Unwrap() error
Unwrap returns the underlying cause
type ScriptExecutor ¶ added in v1.3.0
type ScriptExecutor interface {
// ExecutePreRequest runs a pre-request script
// Returns modified request data and execution result
ExecutePreRequest(script string, req *ScriptRequest, env *Environment) (*ScriptResult, error)
// ExecutePostResponse runs a post-response script
// Returns execution result with assertions and env changes
ExecutePostResponse(script string, req *ScriptRequest, resp *ScriptResponse, env *Environment) (*ScriptResult, error)
// SetTimeout configures the script execution timeout
SetTimeout(timeout time.Duration)
// GetTimeout returns the current timeout setting
GetTimeout() time.Duration
}
ScriptExecutor handles JavaScript script execution
func NewScriptExecutor ¶ added in v1.3.0
func NewScriptExecutor() ScriptExecutor
NewScriptExecutor creates a new script executor instance
type ScriptGlobals ¶ added in v1.3.0
type ScriptGlobals struct {
// contains filtered or unexported fields
}
ScriptGlobals provides global variable storage accessible across all scripts Unlike ScriptEnvironment which is scoped to a single request execution, ScriptGlobals persists across multiple requests in a session
func NewScriptGlobals ¶ added in v1.3.0
func NewScriptGlobals() *ScriptGlobals
NewScriptGlobals creates a new global variable store
func (*ScriptGlobals) All ¶ added in v1.3.0
func (g *ScriptGlobals) All() map[string]interface{}
All returns a copy of all global variables
func (*ScriptGlobals) Clear ¶ added in v1.3.0
func (g *ScriptGlobals) Clear()
Clear removes all global variables
func (*ScriptGlobals) Get ¶ added in v1.3.0
func (g *ScriptGlobals) Get(name string) interface{}
Get retrieves a global variable value
func (*ScriptGlobals) Has ¶ added in v1.3.0
func (g *ScriptGlobals) Has(name string) bool
Has checks if a global variable exists
func (*ScriptGlobals) Set ¶ added in v1.3.0
func (g *ScriptGlobals) Set(name string, value interface{})
Set sets a global variable value
func (*ScriptGlobals) Unset ¶ added in v1.3.0
func (g *ScriptGlobals) Unset(name string)
Unset removes a global variable
type ScriptInfo ¶ added in v1.3.0
type ScriptInfo struct {
ScriptType string // "pre-request" or "post-response"
RequestName string // Name of the request being executed
RequestID string // ID of the request
CollectionName string // Name of the collection
EnvironmentName string // Name of the active environment
Iteration int // Current iteration (for collection runner)
}
ScriptInfo contains contextual information about the script execution
func NewScriptInfo ¶ added in v1.3.0
func NewScriptInfo() *ScriptInfo
NewScriptInfo creates a new ScriptInfo with defaults
type ScriptRequest ¶ added in v1.3.0
type ScriptRequest struct {
// contains filtered or unexported fields
}
ScriptRequest represents mutable request data for scripts
func NewScriptRequest ¶ added in v1.3.0
func NewScriptRequest(req *CollectionRequest) *ScriptRequest
NewScriptRequest creates a ScriptRequest from a CollectionRequest
func NewScriptRequestFromHTTP ¶ added in v1.3.0
func NewScriptRequestFromHTTP(req *Request) *ScriptRequest
NewScriptRequestFromHTTP creates a ScriptRequest from an HTTP Request
func (*ScriptRequest) ApplyTo ¶ added in v1.3.0
func (r *ScriptRequest) ApplyTo(req *CollectionRequest)
ApplyTo applies the modifications to a CollectionRequest
func (*ScriptRequest) Body ¶ added in v1.3.0
func (r *ScriptRequest) Body() string
Body returns the request body
func (*ScriptRequest) GetHeader ¶ added in v1.3.0
func (r *ScriptRequest) GetHeader(name string) string
GetHeader returns a header value (case-insensitive)
func (*ScriptRequest) Headers ¶ added in v1.3.0
func (r *ScriptRequest) Headers() map[string]string
Headers returns a copy of all headers
func (*ScriptRequest) IsBodyModified ¶ added in v1.3.0
func (r *ScriptRequest) IsBodyModified() bool
IsBodyModified returns true if the body was explicitly modified by a script
func (*ScriptRequest) IsModified ¶ added in v1.3.0
func (r *ScriptRequest) IsModified() bool
IsModified returns true if the request was modified by a script
func (*ScriptRequest) Method ¶ added in v1.3.0
func (r *ScriptRequest) Method() string
Method returns the HTTP method (readonly)
func (*ScriptRequest) Name ¶ added in v1.3.0
func (r *ScriptRequest) Name() string
Name returns the request name
func (*ScriptRequest) RemoveHeader ¶ added in v1.3.0
func (r *ScriptRequest) RemoveHeader(name string)
RemoveHeader removes a header (case-insensitive) and marks as modified
func (*ScriptRequest) SetBody ¶ added in v1.3.0
func (r *ScriptRequest) SetBody(body string)
SetBody sets the request body and marks as modified
func (*ScriptRequest) SetHeader ¶ added in v1.3.0
func (r *ScriptRequest) SetHeader(name, value string)
SetHeader sets or updates a header value and marks as modified
func (*ScriptRequest) SetURL ¶ added in v1.3.0
func (r *ScriptRequest) SetURL(url string)
SetURL sets the request URL and marks as modified
func (*ScriptRequest) URL ¶ added in v1.3.0
func (r *ScriptRequest) URL() string
URL returns the request URL
type ScriptResponse ¶ added in v1.3.0
type ScriptResponse struct {
// contains filtered or unexported fields
}
ScriptResponse represents immutable response data for scripts
func NewScriptResponse ¶ added in v1.3.0
NewScriptResponse creates a ScriptResponse from an HTTP response
func NewScriptResponseFromData ¶ added in v1.3.0
func NewScriptResponseFromData(status int, statusText string, headers map[string]string, body string, timeMs int64) *ScriptResponse
NewScriptResponseFromData creates a ScriptResponse from raw data
func (*ScriptResponse) Body ¶ added in v1.3.0
func (r *ScriptResponse) Body() string
Body returns the response body as string
func (*ScriptResponse) GetHeader ¶ added in v1.3.0
func (r *ScriptResponse) GetHeader(name string) string
GetHeader returns a header value (case-insensitive)
func (*ScriptResponse) Headers ¶ added in v1.3.0
func (r *ScriptResponse) Headers() map[string]string
Headers returns a copy of all headers
func (*ScriptResponse) Status ¶ added in v1.3.0
func (r *ScriptResponse) Status() int
Status returns the HTTP status code
func (*ScriptResponse) StatusText ¶ added in v1.3.0
func (r *ScriptResponse) StatusText() string
StatusText returns the full status text (e.g., "200 OK")
func (*ScriptResponse) Time ¶ added in v1.3.0
func (r *ScriptResponse) Time() int64
Time returns the response time in milliseconds
type ScriptResult ¶ added in v1.3.0
type ScriptResult struct {
// Execution status
Success bool `json:"success"`
Duration time.Duration `json:"duration"`
// Error information (if failed)
Error *ScriptErrorInfo `json:"error,omitempty"`
// Console output
ConsoleOutput []ConsoleLogEntry `json:"console_output"`
// Assertion results
Assertions []AssertionResult `json:"assertions"`
// Environment changes made by script
EnvChanges []EnvChange `json:"env_changes"`
// Request modifications (pre-request only)
RequestModified bool `json:"request_modified"`
}
ScriptResult contains the outcome of script execution
func NewScriptResult ¶ added in v1.3.0
func NewScriptResult() *ScriptResult
NewScriptResult creates a new successful result
func NewScriptResultWithError ¶ added in v1.3.0
func NewScriptResultWithError(err error) *ScriptResult
NewScriptResultWithError creates a result with an error
func (*ScriptResult) FailedAssertionCount ¶ added in v1.3.0
func (r *ScriptResult) FailedAssertionCount() int
FailedAssertionCount returns the number of failed assertions
func (*ScriptResult) HasAssertionFailures ¶ added in v1.3.0
func (r *ScriptResult) HasAssertionFailures() bool
HasAssertionFailures returns true if any assertion failed
func (*ScriptResult) PassedAssertionCount ¶ added in v1.3.0
func (r *ScriptResult) PassedAssertionCount() int
PassedAssertionCount returns the number of passed assertions
func (*ScriptResult) SetError ¶ added in v1.3.0
func (r *ScriptResult) SetError(err error)
SetError sets the error information from an error
type ScriptSyntaxError ¶ added in v1.3.0
ScriptSyntaxError indicates JavaScript syntax error
func (*ScriptSyntaxError) Error ¶ added in v1.3.0
func (e *ScriptSyntaxError) Error() string
Error implements the error interface
type ScriptTimeoutError ¶ added in v1.3.0
ScriptTimeoutError indicates script exceeded time limit
func (*ScriptTimeoutError) Error ¶ added in v1.3.0
func (e *ScriptTimeoutError) Error() string
Error implements the error interface
type TempFileInfo ¶ added in v1.2.0
type TempFileInfo struct {
// Path is the absolute path to the temp file
Path string
// OriginalContent is the content before editing
// Used for comparison and recovery
OriginalContent string
// ContentType is the detected content type
ContentType ContentType
// Extension is the file extension (with dot)
Extension string
// CreatedAt is when the file was created
CreatedAt time.Time
}
TempFileInfo holds metadata about a temporary file
func CreateTempFile ¶ added in v1.2.0
func CreateTempFile(content string, contentType ContentType) (*TempFileInfo, error)
CreateTempFile creates a temporary file with the given content. The file extension is determined by the content type.
The temp file is created in the system temp directory with the prefix "lazycurl-" for identification.
Caller is responsible for cleanup via CleanupTempFile.
Source Files
¶
- collection.go
- console.go
- curl_generator.go
- curl_parser.go
- environment.go
- external_editor.go
- headers.go
- http.go
- openapi.go
- openapi_converter.go
- script_assertions.go
- script_base64.go
- script_console.go
- script_cookies.go
- script_crypto.go
- script_env.go
- script_errors.go
- script_executor.go
- script_globals.go
- script_info.go
- script_request.go
- script_response.go
- script_result.go
- script_variables.go
- temp_file.go
- variables.go