Documentation
¶
Overview ¶
Package dump provides HTTP request/response capturing and display functionality. It includes console output formatting and a web-based inspector interface.
Package dump provides HTTP request/response capturing and display functionality. It includes console output formatting and a web-based inspector interface.
Package dump provides HTTP request/response capturing and display functionality. It includes console output formatting and a web-based inspector interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var IndexHTML string
Functions ¶
This section is empty.
Types ¶
type BinaryData ¶
type BinaryData struct {
Data string `json:"data"`
}
BinaryData represents binary content as a hex-encoded string.
type ConsoleDumper ¶
type ConsoleDumper struct {
// contains filtered or unexported fields
}
ConsoleDumper prints HTTP dump information to the console in a formatted table with support for verbose mode and configurable table width.
func NewConsoleDumper ¶
func NewConsoleDumper(opts ...Opts) *ConsoleDumper
NewConsoleDumper creates a new ConsoleDumper with default options (non-verbose mode, 80 character table width).
func (*ConsoleDumper) Dump ¶
func (cd *ConsoleDumper) Dump(d *Dump)
Dump prints the HTTP dump to console
type ConsoleDumperOptions ¶
type ConsoleDumperOptions struct {
Verbose bool
TableWidth int // Total table width (default: 80)
MaxBodyWidth int // Maximum width for body content (default: 72)
}
ConsoleDumperOptions defines options for creating a ConsoleDumper.
type Data ¶
type Data struct {
Headers http.Header `json:"headers,omitempty"`
Cookies []*http.Cookie `json:"cookies,omitempty"`
ContentType string `json:"contentType,omitempty"`
Body any `json:"body,omitempty"`
RawBody string `json:"rawBody,omitempty"`
IsBinary bool `json:"isBinary"`
}
Data contains parsed HTTP request or response data including headers, cookies, content type, and body (which may be structured or binary).
type Dump ¶
type Dump struct {
ID string `json:"id"`
RequestDump *RequestData `json:"request"`
ResponseDump *ResponseData `json:"response"`
Timestamp string `json:"timestamp"`
}
Dump contains a complete captured HTTP transaction including request details, response details, and metadata like ID and timestamp.
func NewDump ¶
func NewDump(req *http.Request, res *http.Response, requestBody []byte, responseBody []byte) (*Dump, error)
NewDump creates a new Dump from HTTP request and response data. It captures headers, cookies, body content, and metadata, then parses the body based on content type (form, multipart, image, PDF, binary, or text).
type HttpDumper ¶
type HttpDumper struct {
// contains filtered or unexported fields
}
HttpDumper manages Server-Sent Events (SSE) connections for broadcasting request dumps to connected web clients in real-time.
func NewHttpDumper ¶
func NewHttpDumper() *HttpDumper
NewHttpDumper creates a new HttpDumper instance that manages SSE connections for real-time request broadcasting to web clients.
func (*HttpDumper) Dump ¶
func (u *HttpDumper) Dump(dump *Dump)
Dump broadcasts a request/response dump to all connected SSE clients.
func (*HttpDumper) Serve ¶
func (u *HttpDumper) Serve(w http.ResponseWriter, r *http.Request)
Serve handles HTTP requests for the web interface. It serves the HTML page for regular requests and establishes SSE connections for requests with Accept: text/event-stream header.
type ImageData ¶
type ImageData struct {
BinaryData
}
ImageData represents image content with binary data.
type Opts ¶
type Opts func(c *ConsoleDumper)
Opts is a function type for configuring ConsoleDumper instances.
func WithTableWidth ¶
WithTableWidth returns an option function that sets the table width.
func WithVerbose ¶
WithVerbose returns an option function that enables or disables verbose output.
type PDFData ¶
type PDFData struct {
BinaryData
PDFPages int `json:"pdfPages"`
FirstPage string `json:"-"`
}
PDFData represents PDF content with page count and first page preview.
type RequestData ¶
type RequestData struct {
Data
Method string `json:"method,omitempty"`
URL string `json:"url,omitempty"`
Path string `json:"path,omitempty"`
Query url.Values `json:"query,omitempty"`
}
RequestData contains captured HTTP request information including method, URL, path, query parameters, and embedded Data fields.
type ResponseData ¶
type ResponseData struct {
Data
StatusCode int `json:"statusCode"`
StatusLine string `json:"statusLine,omitempty"`
}
ResponseData contains captured HTTP response information including status code, status line, and embedded Data fields.
type ServerResetEvent ¶
ServerResetEvent is sent to SSE clients when the server restarts, allowing clients to clear old data and synchronize with the new server instance.