v0.1.2

Internal Packages

This page documents the exported types and functions of internal/ui and internal/parser for anyone modifying or extending the source; both live under internal/ and cannot be imported from other modules.

internal/ui

TUI

type TUI struct {
    App       *tview.Application
    Pages     *tview.Pages
    LeftView  *tview.List
    RightView *tview.TextView
    HintView  *tview.TextView
    Watcher   *fsnotify.Watcher
    Filepath  string
    Requests  []*Request
    Mu        sync.RWMutex
}
Field Description
App The tview application; background updates must go through App.QueueUpdateDraw
Pages Created but never added to the layout; currently unused
LeftView Request list (API pane)
RightView Request preview and response (Info pane)
HintView One-row hint bar at the bottom
Watcher fsnotify watcher assigned by main
Filepath Path of the loaded .http file, set by parser.ReadFile
Requests Parse result; hold Mu when reading or writing
Mu Read-write lock guarding Requests

Request

type Request struct {
    Name    string
    Method  string
    URL     string
    Headers map[string]string
    Body    string
}

The parse result of one .http request block; the last entry wins for duplicate Headers keys.

Functions and Methods

Symbol Signature Description
NewTUI func NewTUI() *TUI Builds the two-pane layout and hint bar and registers global keys (Tab, ←, →, Ctrl+C, Esc)
UpdateLeftView func (t *TUI) UpdateLeftView() Rebuilds the list from Requests, binds Enter to send and cursor moves to preview, and previews the first request

internal/parser

Symbol Signature Description
ReadFile func ReadFile(t *ui.TUI, path string) ([]*ui.Request, error) Sets t.Filepath, parses the whole file, writes t.Requests, and calls UpdateLeftView; returns a wrapped error when opening or reading fails
WatchFile func WatchFile(t *ui.TUI) Reads events and errors from t.Watcher until the channels close; fsnotify.Write/fsnotify.Create call ReloadFile after a 200ms debounce
ReloadFile func ReloadFile(t *ui.TUI) Re-parses t.Filepath, refreshes the list, restores the cursor by index, and reports the result in the hint bar

See .http File Format for syntax and Hot Reload for reload behavior.

中文