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) Exchanges ¶
func (p *Proxy) Exchanges() []CapturedExchange
Exchanges returns a snapshot of all captured exchanges.
func (*Proxy) ListenPort ¶
ListenPort returns the port the proxy is listening on, or 0 if not started.
func (*Proxy) Replay ¶
Replay resends a previously captured request through the proxy. The replayed exchange is captured as a new entry with IsReplay=true.
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.