Documentation
¶
Index ¶
- Constants
- func ParseFile(filePath string, defaultHeaders map[string]string) ([]*models.HttpRequest, error)
- func ParseFileAt(filePath string, index int, defaultHeaders map[string]string) (*models.HttpRequest, error)
- func ParseFileByName(filePath string, name string, defaultHeaders map[string]string) (*models.HttpRequest, error)
- type HttpRequestParser
- type ParseResult
- type ParseState
- type ParseWarning
Constants ¶
const RequestDelimiter = "###"
RequestDelimiter is used to separate multiple requests in one file
Variables ¶
This section is empty.
Functions ¶
func ParseFileAt ¶
func ParseFileAt(filePath string, index int, defaultHeaders map[string]string) (*models.HttpRequest, error)
ParseFileAt parses a specific request from a file (by index)
func ParseFileByName ¶
func ParseFileByName(filePath string, name string, defaultHeaders map[string]string) (*models.HttpRequest, error)
ParseFileByName parses a named request from a file
Types ¶
type HttpRequestParser ¶
type HttpRequestParser struct {
// contains filtered or unexported fields
}
HttpRequestParser parses HTTP request files (.http, .rest)
func NewHttpRequestParser ¶
func NewHttpRequestParser(content string, defaultHeaders map[string]string, baseDir string) *HttpRequestParser
NewHttpRequestParser creates a new parser
func (*HttpRequestParser) ParseAll ¶
func (p *HttpRequestParser) ParseAll() ([]*models.HttpRequest, error)
ParseAll parses all requests from the content (backward compatible - ignores warnings)
func (*HttpRequestParser) ParseAllWithWarnings ¶ added in v0.2.4
func (p *HttpRequestParser) ParseAllWithWarnings() *ParseResult
ParseAllWithWarnings parses all requests and returns warnings for invalid blocks
func (*HttpRequestParser) ParseRequest ¶
func (p *HttpRequestParser) ParseRequest(rawText string) (*models.HttpRequest, error)
ParseRequest parses a single HTTP request from text
type ParseResult ¶ added in v0.2.4
type ParseResult struct {
Requests []*models.HttpRequest
Warnings []ParseWarning
}
ParseResult contains the parsed requests and any warnings
func ParseFileWithWarnings ¶ added in v0.2.4
func ParseFileWithWarnings(filePath string, defaultHeaders map[string]string) (*ParseResult, error)
ParseFileWithWarnings parses an HTTP request file and returns warnings
type ParseState ¶
type ParseState int
ParseState represents the current state of parsing
const ( ParseStateURL ParseState = iota ParseStateHeader ParseStateBody ParseStatePostScript )
type ParseWarning ¶ added in v0.2.4
type ParseWarning struct {
BlockIndex int // Index of the block (0-based)
Line int // Line number within the block (0-based)
Message string // Warning message
}
ParseWarning represents a warning generated during parsing