v0.1.2

Architecture

Last updated


This page shows go-rest-client's layers and cross-layer rules in a single overview diagram; module internals, sequence diagrams, and the state machine live in doc/architecture.md.

System Overview


graph TB
    CLI[cmd/tui entry] -->|file path| P[internal/parser]
    CLI -->|create| T[internal/ui TUI]
    CLI -->|create| W[fsnotify Watcher]
    F[.http File] --> P
    W -->|Write / Create events| P
    P -->|Requests| T
    T -->|Enter| H[net/http Client]
    H -->|regular response| R[handleResponse]
    H -->|text/event-stream| S[handleSSEResponse]
    R --> V[Info pane]
    S --> V
  1. graph TB
  2. CLI[cmd/tui entry] -->|file path| P[internal/parser]
  3. CLI -->|create| T[internal/ui TUI]
  4. CLI -->|create| W[fsnotify Watcher]
  5. F[.http File] --> P
  6. W -->|Write / Create events| P
  7. P -->|Requests| T
  8. T -->|Enter| H[net/http Client]
  9. H -->|regular response| R[handleResponse]
  10. H -->|text/event-stream| S[handleSSEResponse]
  11. R --> V[Info pane]
  12. S --> V

Layers


LayerPathResponsibility
Entrycmd/tui/main.goValidate arguments, create the watcher and TUI, run the initial parse, start the event loop
Parsinginternal/parser/parser.goLine-by-line .http parsing, header name validation, file watching and reload
UI and transportinternal/ui/tui.gotview layout, key bindings, sending HTTP requests, rendering regular and SSE responses

Both packages live under internal/ and cannot be imported by other modules; parser depends on the ui types TUI and Request, while ui does not depend on parser.

Cross-Layer Rules


RuleImplementation
Response rendering is queued to the event loopThe send goroutine and the reload timer update the info pane and hint bar via App.QueueUpdateDraw; ReadFile calls UpdateLeftView directly on its calling goroutine (main at startup, the timer goroutine on reload)
The request list is lock-protectedTUI.Requests is guarded by a sync.RWMutex (TUI.Mu) so reload writes and send reads do not interfere
Sending never blocks the UIEach <kbd>Enter</kbd> runs in its own goroutine with a 120-second context timeout
Reloads are debouncedA 200ms timer merges bursts of write events; the timer itself is mutex-protected
中文