inspector

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package inspector provides an HTTP reverse proxy with request/response capture and a terminal UI for inspecting and replaying traffic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaptureMsg

type CaptureMsg CapturedExchange

CaptureMsg is sent to the TUI when a new exchange is captured.

type CapturedExchange

type CapturedExchange struct {
	ID        int
	Timestamp time.Time
	IsReplay  bool

	// Request
	Method     string
	Path       string
	Query      string
	Host       string
	ReqHeaders http.Header
	ReqBody    []byte

	// Response
	StatusCode  int
	RespHeaders http.Header
	RespBody    []byte
	Duration    time.Duration
}

CapturedExchange holds a recorded HTTP request/response pair.

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy is a reverse proxy that captures HTTP request/response exchanges.

func NewProxy

func NewProxy(targetPort string, onCapture func(CapturedExchange)) (*Proxy, error)

NewProxy creates a new inspector proxy that forwards traffic to targetPort. onCapture is called asynchronously for each captured exchange.

func (*Proxy) Clear

func (p *Proxy) Clear()

Clear removes all captured exchanges and resets the counter.

func (*Proxy) Close

func (p *Proxy) Close() error

Close shuts down the proxy listener.

func (*Proxy) Exchanges

func (p *Proxy) Exchanges() []CapturedExchange

Exchanges returns a snapshot of all captured exchanges.

func (*Proxy) ListenPort

func (p *Proxy) ListenPort() int

ListenPort returns the port the proxy is listening on, or 0 if not started.

func (*Proxy) Replay

func (p *Proxy) Replay(id int) error

Replay resends a previously captured request through the proxy. The replayed exchange is captured as a new entry with IsReplay=true.

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP captures the request, proxies it, then captures the response.

func (*Proxy) Start

func (p *Proxy) Start() (int, error)

Start begins listening on a random available port and serving in the background.

type TUIModel

type TUIModel struct {
	// contains filtered or unexported fields
}

TUIModel is the Bubble Tea model for the inspector interface.

func NewTUIModel

func NewTUIModel(proxy *Proxy, ch chan CapturedExchange, tunnelURL, targetPort string, proxyPort int) TUIModel

NewTUIModel creates a new inspector TUI.

func (TUIModel) Init

func (m TUIModel) Init() tea.Cmd

func (TUIModel) Update

func (m TUIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (TUIModel) View

func (m TUIModel) View() string

Jump to

Keyboard shortcuts

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