parser

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const RequestDelimiter = "###"

RequestDelimiter is used to separate multiple requests in one file

Variables

This section is empty.

Functions

func ParseFile

func ParseFile(filePath string, defaultHeaders map[string]string) ([]*models.HttpRequest, error)

ParseFile parses an HTTP request file

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL