Documentation
¶
Index ¶
- Constants
- Variables
- func ActionsPane(th *theme.Theme, opts ActionsOpts) ui.View
- func AddKVRow(t *ui.Table, onChange func())
- func AddVariableRow(t *ui.Table, defaultStatus int, markDirty func())
- func AssistEditor(ed *ui.Editor, src vars.Source) *ui.Editor
- func AssistField(n *ui.Node, src vars.Source) *ui.Node
- func AssistKV(t *ui.Table, src vars.Source)
- func AssistURLField(n *ui.Node, src vars.Source) *ui.Node
- func AuthForm(th *theme.Theme, id string, auth *domain.Auth, st *AuthState, catalog Catalog, ...) ui.View
- func BinaryFilePicker(th *theme.Theme, id, path string, deps Deps, onChange func(string)) ui.View
- func BodyHighlighter(kind string) highlight.Highlighter
- func CookieExpiry(c domain.Cookie, now time.Time) string
- func CookieFlags(c domain.Cookie) string
- func CookiesView(id string, th *theme.Theme, ctx *ui.Ctx, deps Deps, s *CookiesState, raw bool) ui.View
- func CopyCollection(c *domain.Collection) *domain.Collection
- func CopyEnv(e *domain.Environment) *domain.Environment
- func CopyRequest(r *domain.Request) *domain.Request
- func DefaultResponseFilename(kind string) string
- func DisplayBody(res *egress.Response, raw bool) []byte
- func DumpKV(t *ui.Table) []domain.KeyValue
- func DumpVariables(t *ui.Table) []domain.Variable
- func EditorIndent() string
- func EnvEntries(values []domain.KeyValue) []vars.Entry
- func ErrorView(id string, th *theme.Theme, ctx *ui.Ctx, deps Deps, msg string) ui.View
- func FlushAuth(auth *domain.Auth, st AuthState)
- func FlushPostScript(post *domain.PostRequest, ed *ui.Editor)
- func FlushPreScript(pre *domain.PreRequest, ed *ui.Editor)
- func FormDataPane(th *theme.Theme, id string, fields *[]domain.FormField, deps Deps, ...) ui.View
- func FormatBytes(n int) string
- func FormatJSONBody(body, indent string) (string, error)
- func FormatJSONEditor(ed *ui.Editor, deps Deps)
- func FormatKeyValues(items []domain.KeyValue, title string) string
- func GRPCPostFromOptions() []ui.SelectOption
- func HTTPPostFromOptions() []ui.SelectOption
- func HeadersPane(th *theme.Theme, id string, headers *ui.Table, collectionID string, ...) ui.View
- func HighlightOffNotice(ed *ui.Editor) ui.View
- func InfoPane(th *theme.Theme, id string, req *domain.Request, descEd *ui.Editor, ...) ui.View
- func JSONBodyEditor(id string, ed *ui.Editor, deps Deps, topRight *ui.Node) ui.View
- func LoadKV(t *ui.Table, items []domain.KeyValue)
- func LoadVariables(t *ui.Table, items []domain.Variable)
- func MetadataPane(th *theme.Theme, id string, metadata *ui.Table, collectionID string, ...) ui.View
- func MutedParagraph(s string) *ui.Node
- func NewBodyEditor(deps Deps, name, bodyType string, body []byte, opts ...ui.EditorOption) *ui.Editor
- func NewDescriptionEditor(description string) *ui.Editor
- func NewKVTable(idPrefix string, onChange func()) *ui.Table
- func NewResponseEditor(data []byte, hl highlight.Highlighter, opts ...ui.EditorOption) *ui.Editor
- func NewScriptEditor(deps Deps, phase scripting.Phase, name, script string) *ui.Editor
- func NewSecretKVTable(idPrefix string, onChange func(), s SecretsUI) *ui.Table
- func NewVariablesTable(id string, fromOptions []ui.SelectOption, markDirty func()) *ui.Table
- func ParamEntries(t *ui.Table) []vars.Entry
- func PickFolder(deps Deps, title string, onPick func(string))
- func PickProtoFiles(deps Deps, onPick func([]string))
- func PostRequestNotice(id string, ctx *ui.Ctx, deps Deps, res *egress.Response) ui.View
- func PostRequestPane(th *theme.Theme, deps Deps, post *domain.PostRequest, opts PrePostOpts, ...) ui.View
- func PreRequestPane(th *theme.Theme, deps Deps, pre *domain.PreRequest, opts PrePostOpts, ...) ui.View
- func PreviewPostSet(set domain.PostRequestSet, res *egress.Response) string
- func RenameCollection(deps Deps, col *domain.Collection, name string)
- func RenameEnvironment(deps Deps, env *domain.Environment, name string)
- func RenameRequest(deps Deps, req *domain.Request, name string)
- func ReplaceEditor(old *ui.Editor, data []byte, hl highlight.Highlighter) *ui.Editor
- func ReplaceResponseEditor(old *ui.Editor, res *egress.Response, raw bool) *ui.Editor
- func RequestBreadcrumb(req *domain.Request) string
- func ResponseEditorMenu(ed *ui.Editor, ctx *ui.Ctx, deps Deps, defaultName string) ui.View
- func ResponseTabsRow(id string, th *theme.Theme, tabs []ui.TabModel, selected int, ...) ui.View
- func SaveEditorBytes(deps Deps, defaultName string, data []byte)
- func SetEnvForm(th *theme.Theme, id string, set *domain.PostRequestSet, ...) ui.View
- func ShowCodeDialog(c *ui.Ctx, deps Deps, req *domain.Request)
- func SimpleTitleRow(th *theme.Theme, id, name string, onSave func(string), actions ...ui.View) ui.View
- func SplitPaneAxis(useHorizontalSplit bool) ui.Axis
- func StatusLineStyle(err bool, code int, haveResult bool) ui.Spec
- func StyleCodeEditor(ed *ui.Editor) *ui.Editor
- func SyncParamsFromURL(url string, existingPath []domain.KeyValue) (query []domain.KeyValue, path []domain.KeyValue)
- func SyncURLFromParams(url string, queryParams []domain.KeyValue) string
- func TimelineView(id string, th *theme.Theme, ctx *ui.Ctx, deps Deps, state *TimelineState, ...) ui.View
- func TriggerRequestPicker(th *theme.Theme, deps Deps, id string, tr *domain.TriggerRequest, ...) ui.View
- func UpdateVariablePreviews(t *ui.Table, vars []domain.Variable, res *egress.Response)
- func VarSource(deps Deps, extra func() []vars.Entry) vars.Source
- func VarsFromTable(t *ui.Table) func() []vars.Entry
- type ActionsOpts
- type AuthState
- type Catalog
- type Container
- type CookiesState
- type Deps
- type Kind
- type OpenSpec
- type PrePostOpts
- type Reporter
- type SecretsUI
- type TabIconer
- type TimelineState
Constants ¶
const ( ActionsBefore = 0 ActionsAfter = 1 ActionsExtract = 2 )
ActionsNav indices for ActionsPane.
const FailedStatus = "Request failed"
FailedStatus is the status line text for a request that failed; the error itself is shown in the response pane by ErrorView.
const (
// KVColSecret marks a row whose value is encrypted at rest.
KVColSecret = "sec"
)
Column IDs shared by the key/value tables.
Variables ¶
var CertFileFilters = []ui.FileFilter{{Label: "Certificates", Exts: []string{".pem", ".crt", ".key"}}}
CertFileFilters limit a file dialog to certificate and key files.
Functions ¶
func ActionsPane ¶
func ActionsPane(th *theme.Theme, opts ActionsOpts) ui.View
ActionsPane renders a top horizontal nav with Before / After / Extract content.
func AddVariableRow ¶
func AssistEditor ¶
AssistEditor gives a code editor the same variable completion and hover as the single-line fields. A body or a script may hold {{name}} placeholders wherever text is allowed, and a language server, when one is attached, keeps answering for everything else. It also lays the editor out with StyleCodeEditor.
func AssistField ¶
AssistField gives a text field variable highlighting, completion, and a hover card explaining the placeholder under the pointer.
func AssistKV ¶
AssistKV gives a key/value table's value cells variable highlighting and completion. Keys are left alone: chapar substitutes values, not names.
func AssistURLField ¶
AssistURLField is AssistField for an address bar, where {name} path parameters are marked up as well as {{name}} variables.
func AuthForm ¶
func AuthForm(th *theme.Theme, id string, auth *domain.Auth, st *AuthState, catalog Catalog, markDirty func()) ui.View
AuthForm builds the auth type selector and sub-forms.
func BinaryFilePicker ¶
BinaryFilePicker renders a file picker for binary request bodies.
func BodyHighlighter ¶
func BodyHighlighter(kind string) highlight.Highlighter
BodyHighlighter returns a highlighter for the response body kind.
func CookieExpiry ¶
CookieExpiry describes when a cookie expires relative to now.
func CookieFlags ¶
CookieFlags lists a cookie's attributes compactly, e.g. "Secure HttpOnly Lax".
func CookiesView ¶
func CookiesView(id string, th *theme.Theme, ctx *ui.Ctx, deps Deps, s *CookiesState, raw bool) ui.View
CookiesView is the response Cookies tab. raw shows the headers as text.
func CopyCollection ¶
func CopyCollection(c *domain.Collection) *domain.Collection
func CopyEnv ¶
func CopyEnv(e *domain.Environment) *domain.Environment
func DefaultResponseFilename ¶
DefaultResponseFilename picks a filename from body kind.
func DisplayBody ¶
DisplayBody returns bytes for the response editor. When raw is true, the original body is shown; otherwise Pretty is preferred when available.
The result may be the response's own body buffer rather than a copy, so callers must treat it as read-only. Nothing mutates a response body once it is built, which is what lets the editor share it instead of copying tens of megabytes per tab — see ReplaceResponseEditor.
func EditorIndent ¶
func EditorIndent() string
EditorIndent is one level of indentation as the editor settings ask for it.
func EnvEntries ¶
EnvEntries lists an environment's own enabled values, for the environment editor, where there is no active environment to read from.
func ErrorView ¶
ErrorView shows a failed request: the confused Chapar with msg under it in red. Right-click copies the message.
func FlushPostScript ¶
func FlushPostScript(post *domain.PostRequest, ed *ui.Editor)
func FlushPreScript ¶
func FlushPreScript(pre *domain.PreRequest, ed *ui.Editor)
func FormDataPane ¶
func FormDataPane(th *theme.Theme, id string, fields *[]domain.FormField, deps Deps, markDirty func()) ui.View
FormDataPane renders multipart form fields.
func FormatBytes ¶
FormatBytes returns a human-readable size (e.g. "1.2 kB").
func FormatJSONBody ¶
FormatJSONBody indents a JSON request body, keeping its {{variable}} placeholders.
A body may hold a placeholder where a value goes ({"id": {{id}}}), which is not JSON until the variable is substituted at send time. Each bare placeholder is swapped for a string sentinel before indenting and swapped back after, so it survives formatting exactly as written. A general-purpose formatter would drop it, silently losing part of the body.
indent is one level of indentation. A body that is not JSON, placeholders aside, is returned with the error and should be left as it is.
func FormatJSONEditor ¶
FormatJSONEditor indents the JSON in ed as one edit the user can undo. A body that is not valid JSON is left alone and the reason is shown.
func FormatKeyValues ¶
FormatKeyValues renders key-values as properties text.
func GRPCPostFromOptions ¶
func GRPCPostFromOptions() []ui.SelectOption
func HTTPPostFromOptions ¶
func HTTPPostFromOptions() []ui.SelectOption
func HeadersPane ¶
func HeadersPane(th *theme.Theme, id string, headers *ui.Table, collectionID string, catalog Catalog, markDirty func()) ui.View
HeadersPane shows an editable headers table and optional inherited collection headers.
func HighlightOffNotice ¶
HighlightOffNotice tells the reader why ed shows no syntax colors — its document is over the size limit — and offers to highlight it anyway.
func InfoPane ¶
func InfoPane(th *theme.Theme, id string, req *domain.Request, descEd *ui.Editor, markDirty func()) ui.View
InfoPane builds the Info tab for request containers: optional name override and description.
func JSONBodyEditor ¶
JSONBodyEditor lays out ed, an editor holding a JSON body, with a Format button floating in its bottom-right corner, where it stays in reach however long the body is. topRight, when not nil, floats in the top-right corner, for an action such as loading an example body.
func MetadataPane ¶
func MetadataPane(th *theme.Theme, id string, metadata *ui.Table, collectionID string, catalog Catalog, markDirty func()) ui.View
MetadataPane is HeadersPane for gRPC metadata, without a title: the tab holds nothing else. Collection headers are sent as metadata too, so they are listed as inherited.
func MutedParagraph ¶ added in v0.10.0
MutedParagraph is body text in ForegroundMuted that wraps to its pane's width.
func NewBodyEditor ¶
func NewBodyEditor(deps Deps, name, bodyType string, body []byte, opts ...ui.EditorOption) *ui.Editor
NewBodyEditor returns an editor for a request body of the given domain.RequestBodyType*.
func NewDescriptionEditor ¶
NewDescriptionEditor creates an editor for request metadata.description.
func NewKVTable ¶
func NewResponseEditor ¶ added in v0.9.0
func NewResponseEditor(data []byte, hl highlight.Highlighter, opts ...ui.EditorOption) *ui.Editor
NewResponseEditor returns a read-only, soft-wrapped editor for something a server sent back: a body, headers, metadata or cookies. It can be searched, selected and copied, but not typed into. data is copied.
func NewScriptEditor ¶
NewScriptEditor returns an editor for a Python pre/post-request script. Scripts run against the active environment, so the editor completes and explains the same {{variable}} placeholders the request's fields do.
func NewSecretKVTable ¶
NewSecretKVTable is NewKVTable plus a lock column that marks a row secret and an eye that reveals a secret value.
func NewVariablesTable ¶
func NewVariablesTable(id string, fromOptions []ui.SelectOption, markDirty func()) *ui.Table
NewVariablesTable creates a variables extraction table.
func ParamEntries ¶
ParamEntries lists a table's keys as path-parameter entries.
func PickFolder ¶
PickFolder opens a folder picker, for choosing an import root.
func PickProtoFiles ¶
PickProtoFiles opens a file dialog that takes one or more .proto files.
func PostRequestNotice ¶
PostRequestNotice shows why the post-request actions failed, above a response that still arrived. It is nil when they did not fail. Right-click copies the message.
func PostRequestPane ¶
func PostRequestPane(th *theme.Theme, deps Deps, post *domain.PostRequest, opts PrePostOpts, scriptEd **ui.Editor, preview string, markDirty func()) ui.View
PostRequestPane renders post-request configuration.
func PreRequestPane ¶
func PreRequestPane(th *theme.Theme, deps Deps, pre *domain.PreRequest, opts PrePostOpts, scriptEd **ui.Editor, markDirty func()) ui.View
PreRequestPane renders pre-request configuration.
func PreviewPostSet ¶
func PreviewPostSet(set domain.PostRequestSet, res *egress.Response) string
PreviewPostSet returns a preview value for a post-request set-env rule.
func RenameCollection ¶
func RenameCollection(deps Deps, col *domain.Collection, name string)
RenameCollection persists a collection name immediately on EditableLabel commit.
func RenameEnvironment ¶
func RenameEnvironment(deps Deps, env *domain.Environment, name string)
RenameEnvironment persists an environment name immediately on EditableLabel commit.
func RenameRequest ¶
RenameRequest persists a request name immediately on EditableLabel commit.
func ReplaceEditor ¶
ReplaceEditor closes the previous editor and returns a new read-only one with data. data is copied, so the caller may keep using it.
func ReplaceResponseEditor ¶
ReplaceResponseEditor rebuilds the response body editor for res.
The editor is built over the display bytes without copying them. Response bodies and their formatted forms are never modified after the response is built, so the editor can read them in place; for a large body that saves a full copy of the document per tab.
func RequestBreadcrumb ¶
RequestBreadcrumb returns collection prefix text for a request.
func ResponseEditorMenu ¶
ResponseEditorMenu adds Save… to the editor's right-click menu and makes Copy take the whole body when nothing is selected.
func ResponseTabsRow ¶
func ResponseTabsRow(id string, th *theme.Theme, tabs []ui.TabModel, selected int, onSelect func(i int, title string), raw bool, onRawChange func(raw bool)) ui.View
ResponseTabsRow lays out response tabs with a stable Raw checkbox on the right so switching tabs does not change chrome height.
func SaveEditorBytes ¶
SaveEditorBytes opens a save dialog and writes data to the chosen path.
func SetEnvForm ¶
func SetEnvForm(th *theme.Theme, id string, set *domain.PostRequestSet, fromOpts []ui.SelectOption, defaultFrom string, markDirty func()) ui.View
func ShowCodeDialog ¶
ShowCodeDialog opens a modal with generated HTTP request code.
func SimpleTitleRow ¶
func SimpleTitleRow(th *theme.Theme, id, name string, onSave func(string), actions ...ui.View) ui.View
SimpleTitleRow is the title row for collection and environment containers: [EditableLabel name] … actions.
func SplitPaneAxis ¶
SplitPaneAxis returns splitter axis from horizontal-split preference.
func StatusLineStyle ¶
StatusLineStyle returns text style for a response status line.
func StyleCodeEditor ¶ added in v0.12.0
StyleCodeEditor sets up how a code editor lays out its text: wrapped rows hang one tab stop past their line's indent, so nested JSON keeps its shape, and the line-number gutter is only as wide as its digits.
func SyncParamsFromURL ¶
func SyncParamsFromURL(url string, existingPath []domain.KeyValue) (query []domain.KeyValue, path []domain.KeyValue)
SyncParamsFromURL parses query and path params from a URL, preserving existing path values.
func SyncURLFromParams ¶
SyncURLFromParams rebuilds the URL query string from query params.
func TimelineView ¶
func TimelineView(id string, th *theme.Theme, ctx *ui.Ctx, deps Deps, state *TimelineState, steps []egress.TimelineStep) ui.View
TimelineView renders a waterfall table of steps with a detail card below.
func TriggerRequestPicker ¶
func UpdateVariablePreviews ¶
UpdateVariablePreviews fills preview cells from the last response.
Types ¶
type ActionsOpts ¶
type ActionsOpts struct {
ID string
Selected *int
Deps Deps
Pre *domain.PreRequest
Post *domain.PostRequest
PreOpts PrePostOpts
PostOpts PrePostOpts
PreScript **ui.Editor
PostScript **ui.Editor
Preview string
// Vars is the response-extractor table. Nil omits the Extract nav item (GraphQL).
Vars *ui.Table
DefaultVarStatus int
MarkDirty func()
}
ActionsOpts configures the Actions request tab (Before / After / Extract).
type AuthState ¶
type AuthState struct {
Type string
User, Pass string
Token string
Key, Val string
CollectionID string
AllowInherit bool
// Vars is what the auth fields complete and paint their {{variable}}
// placeholders from. The zero value offers nothing.
Vars vars.Source
}
AuthState holds auth form field values for a container.
func LoadAuthState ¶
LoadAuthState reads domain auth into AuthState.
type Catalog ¶
type Catalog interface {
RequestByID(id string) *domain.Request
CollectionByID(id string) *domain.Collection
EnvironmentByID(id string) *domain.Environment
ReplaceEnvironment(env *domain.Environment)
Load() error
AllCollections() []*domain.Collection
StandaloneRequests() []*domain.Request
// AllRequests returns every request, with CollectionName set on those
// in a collection.
AllRequests() []*domain.Request
AllEnvironments() []*domain.Environment
}
Catalog is the subset of app catalog a container may query.
type Container ¶
type Container interface {
ID() string
Kind() Kind
Title() string
Dirty() bool
Layout(c *ui.Ctx) ui.View
Close()
Save() error
Send()
}
Container is the only editor contract. Protocol-specific UI stays inside each implementation.
type CookiesState ¶
type CookiesState struct {
// contains filtered or unexported fields
}
CookiesState holds the response Cookies tab: what the server set and what the cookie jar sent.
type Deps ¶
type Deps struct {
Repo repository.RepositoryV2
Catalog Catalog
Sender *sender.Service
Dialogs func() *ui.DialogHost
Files func() *ui.FileDialog
Toasts func() *ui.ToastHost
Wake func()
ActiveEnv func() *domain.Environment
Report Reporter
// Lang creates code editors wired to language servers. Nil means
// highlighting only.
Lang *langsrv.Service
// ManageCookies opens the cookie jar dialog. Nil hides the entry points.
ManageCookies func()
// Secrets holds the key that encrypts secret environment values. Nil means
// values cannot be marked secret.
Secrets *secret.Manager
// Clipboard copies text on the user's behalf. Nil hides Copy actions.
Clipboard func(string)
// OpenCollection opens a collection in its own tab, for a container that
// creates one.
OpenCollection func(*domain.Collection)
// Tests runs test cases. Nil hides Run.
Tests *testrun.Runner
}
Deps is everything a container needs to be self-service. Dialogs/Files/Toasts are window services; prefer Report callbacks filled by the app.
func (Deps) ReportDirty ¶
func (Deps) ReportTitle ¶
type OpenSpec ¶
type OpenSpec struct {
Request *domain.Request
Collection *domain.Collection
Env *domain.Environment
TestCase *domain.TestCase
Deps Deps
}
OpenSpec is the factory input. Kind is inferred from the non-nil document.
type PrePostOpts ¶
type PrePostOpts struct {
ID string
AllowPython bool
AllowSetEnv bool
FromOptions []ui.SelectOption
DefaultFrom string
DefaultStatus int
}
PrePostOpts configures pre/post request UI options.
type Reporter ¶
type Reporter struct {
Dirty func(dirty bool)
Title func(title string)
Saved func()
Error func(error)
Toast func(msg string)
Refresh func()
}
Reporter is how a container tells the workspace about its own state.
type SecretsUI ¶
type SecretsUI struct {
// Revealed reports whether the user asked to see this row's value.
Revealed func(rowID string) bool
// ToggleReveal flips that.
ToggleReveal func(rowID string)
// OnMarkSecret runs when a row is switched to secret, so the caller can
// make sure a key exists before the value has to be encrypted.
OnMarkSecret func(rowID string)
// Locked reports a row whose value is still encrypted because the key is
// missing; such a row cannot be edited or revealed.
Locked func(rowID string) bool
}
SecretsUI is how a table learns about secret rows: which ones the user chose to reveal, and what to do when a row is marked secret.
type TabIconer ¶
TabIconer is implemented by containers whose workspace tab shows an icon before the title, so requests, collections and environments open side by side can be told apart at a glance.
type TimelineState ¶
type TimelineState struct {
Selected int
// contains filtered or unexported fields
}
TimelineState holds selection and a retained table for the Timeline tab.
func (*TimelineState) EnsureTimelineDetail ¶
func (t *TimelineState) EnsureTimelineDetail()
EnsureTimelineDetail is kept for callers that used the old editor API.
func (*TimelineState) SetSteps ¶
func (t *TimelineState) SetSteps(steps []egress.TimelineStep)
SetSteps refreshes selection, table rows, and detail card from the response timeline.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package testcase is the editor of a test case: its steps, variables and settings, as a form or as YAML, with the results of its last run.
|
Package testcase is the editor of a test case: its steps, variables and settings, as a form or as YAML, with the results of its last run. |
|
Package websocket is the editor for WebSocket requests: a connection the user opens, sends messages on, and watches.
|
Package websocket is the editor for WebSocket requests: a connection the user opens, sends messages on, and watches. |