web

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package web renders relayed traffic in a browser. It implements a relay.Reporter that accumulates transactions and streams them to connected pages over Server-Sent Events; the static front-end does JSON pretty-printing and folding client-side.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(meta Meta, options ...Options) (http.Handler, relay.Reporter)

New builds the web UI handler and the relay.Reporter that feeds it. The reporter is safe to call from request-handling goroutines; mount the handler on a listener separate from the relay's proxy port.

Types

type Body

type Body struct {
	Size      int    `json:"size"`
	Text      string `json:"text,omitempty"`
	Base64    string `json:"base64,omitempty"`
	Truncated bool   `json:"truncated"`
}

Body is a body captured for display. Text is set for valid UTF-8 payloads; otherwise Base64 holds the raw bytes. Either way the content is capped at maxBodyBytes and Truncated records whether anything was dropped.

type Meta

type Meta struct {
	Addr        string `json:"addr"`
	Mode        string `json:"mode"`
	Namespace   string `json:"namespace,omitempty"`
	Proxy       string `json:"proxy"`
	Timeout     string `json:"timeout"`
	Version     string `json:"version"`
	AuthEnabled bool   `json:"authEnabled"`
}

Meta is the relay configuration shown in the page header.

type Options added in v0.6.0

type Options struct {
	AuthKey                     string
	SessionTTL                  time.Duration
	MaxTransactionsPerNamespace int
	JWTAuth                     *appconfig.AuthConfig
	Logger                      *log.Logger
	TrustForwardedHeaders       bool
	MCPEnabled                  bool
}

type Transaction

type Transaction struct {
	Seq            uint64    `json:"seq"`
	Namespace      string    `json:"namespace,omitempty"`
	RewriteProfile string    `json:"rewriteProfile,omitempty"`
	At             time.Time `json:"at"`
	Method         string    `json:"method"`
	Target         string    `json:"target"`
	Status         int       `json:"status"`
	DurationMs     int64     `json:"durationMs"`
	Bytes          int64     `json:"bytes"`
	Err            string    `json:"err,omitempty"`

	ReqHead  string `json:"reqHead,omitempty"`
	ReqBody  *Body  `json:"reqBody,omitempty"`
	RespHead string `json:"respHead,omitempty"`
	RespBody *Body  `json:"respBody,omitempty"`

	HasReq  bool `json:"hasReq"`
	HasResp bool `json:"hasResp"`
	Done    bool `json:"done"`
}

Transaction accumulates everything known about one relayed request, keyed by seq. It mirrors the TUI's txn but is JSON-serializable for the browser.

type TransactionFilter added in v0.17.0

type TransactionFilter struct {
	Method         string
	TargetContains string
	Status         *int
	StatusMin      *int
	StatusMax      *int
	HasError       *bool
	Done           *bool
	From           *time.Time
	To             *time.Time
}

Jump to

Keyboard shortcuts

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