Documentation
¶
Overview ¶
Package httpclient is the HTTP Client extension (SPEC §10.33, "emetos.httpclient"). Step 27.1 builds its files and its variables, without a user interface yet: format reads and writes the collections, folders, requests and environments of a project (the files under .emetos/http), store keeps the tree of them in step with the disk, and variables resolves {{name}} in the order of the SPEC and keeps current values and secrets away from the project. Step 27.2 adds engine, which builds and sends a request and captures the response (SPEC §10.33 "The engine"). Step 27.3 adds this package: the extension itself with its side bar (the Collections, Environments and History views), the status bar item and the picker of the active environment, and the environment editor tab; history keeps the requests that were sent. The request tab, the response pane, extraction and checks and the collection runner (rundata reads its data files) are built; OAuth 2.0 follows in a later step of M27.
Index ¶
Constants ¶
const ( CmdFocus = ID + ".focus" CmdNewCollection = ID + ".newCollection" CmdNewFolder = ID + ".newFolder" CmdNewRequest = ID + ".newRequest" CmdNewEnvironment = ID + ".newEnvironment" CmdOpenRequest = ID + ".openRequest" CmdRename = ID + ".rename" CmdDuplicate = ID + ".duplicate" CmdDelete = ID + ".delete" CmdCopyName = ID + ".copyName" CmdRefresh = ID + ".refresh" CmdCollapseAll = ID + ".collapseAll" CmdSelectEnvironment = ID + ".selectEnvironment" CmdEditEnvironment = ID + ".editEnvironment" CmdOpenHistory = ID + ".openHistory" CmdSaveHistory = ID + ".saveHistoryToCollection" CmdClearHistory = ID + ".clearHistory" CmdSend = ID + ".send" CmdCancel = ID + ".cancel" CmdSave = ID + ".save" CmdOpenAsText = ID + ".openAsText" CmdRunCollection = ID + ".runCollection" CmdGetNewAccessToken = ID + ".getNewAccessToken" CmdClearAccessToken = ID + ".clearAccessToken" )
The commands of the extension (SPEC §10.33 "Commands"), in the category "HTTP Client".
const ( // ID is the id of the extension. ID = "emetos.httpclient" // ContainerID is the view container of the activity bar, "HTTP Client". ContainerID = ID + ".container" // CollectionsViewID, EnvironmentsViewID and HistoryViewID are the three views of the container. CollectionsViewID = ID + ".collections" EnvironmentsViewID = ID + ".environments" HistoryViewID = ID + ".history" // EnvironmentKindID is the kind of editor tab of the environment editor. EnvironmentKindID = ID + ".environment" // StatusEnvironmentID is the item of the status bar that names the active environment. StatusEnvironmentID = "environment" )
The ids of the extension: the container of the activity bar and its three views, the editor kind of the environment editor, and the item of the status bar.
const ( SettingTimeoutMs = "httpClient.timeoutMs" SettingVerifyTLS = "httpClient.verifyTls" SettingProxy = "httpClient.proxy" SettingClientCerts = "httpClient.clientCertificates" SettingHistoryLimit = "httpClient.historyLimit" SettingResponseLayout = "httpClient.responseLayout" SettingAllowedProcessEnv = "httpClient.allowedProcessEnv" SettingMaxResponseMiB = "httpClient.maxResponseMiB" )
The settings of the extension (SPEC §10.33 "Commands"). Their keys are the SPEC's, not under the id of the extension.
const CommandDevEcho = "dev.httpclient.echo"
CommandDevEcho is the dev command that starts a small HTTP server on 127.0.0.1 that answers every request with a description of it (its method, path, query, headers and body as JSON), for the proofs of the request tab and the response pane (SPEC §15.2). It sets the current value of the variable baseUrl of the active environment to the address of the server, so that a request with {{baseUrl}} reaches it. The server stops with the window. It exists in debug builds only.
const CommandDevFakeOAuth = "dev.httpclient.fakeOAuth"
CommandDevFakeOAuth is the dev command that starts a fake OAuth 2.0 authorization server on 127.0.0.1 (client "emetos-dev", secret "dev-secret"; the endpoints /authorize and /token), sets the variable authBase of the active environment to its address, makes "Get New Access Token" follow the authorization page itself instead of opening a browser, and keeps tokens in memory instead of the keyring, for the proof of step 27.8 (SPEC §15.2). It exists in debug builds only.
const CommandDevSeedHistory = "dev.httpclient.seedHistory"
CommandDevSeedHistory is the dev command that fills the history with a few requests of today and yesterday, for the proof of the side bar (SPEC §15.2): the history is kept in Emetos's state, so a fixture folder cannot carry it. It exists in debug builds only.
const RequestKindID = ID + ".request"
RequestKindID is the kind of editor tab of the request tab (SPEC §10.33 "The request tab").
const RunnerKindID = ID + ".runner"
RunnerKindID is the kind of editor tab of the collection runner (SPEC §10.33 "The collection runner").
const (
// StateActiveEnvironment holds the key (the file name without its extension) of the active environment as a JSON string.
StateActiveEnvironment = "httpclient.activeEnvironment"
)
The keys of the state of the workspace (extension.State) the extension keeps; the history and the current values have theirs in package history and package variables.
const StateAsText = "httpclient.asText"
StateAsText holds, as a JSON list, the request files that the person opened as text, so that opening them again (and a restart) does not turn them into request tabs.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Extension ¶
type Extension struct {
// contains filtered or unexported fields
}
Extension is the HTTP Client in one workspace.
type Options ¶
type Options struct {
// Keyring keeps the values of secret variables; the desktop's Secret Service when nil.
Keyring variables.Secrets
// Now is the clock; time.Now when nil.
Now func() time.Time
// Browser shows the authorization page of OAuth 2.0 to the user; the desktop's browser (Workspace().OpenURI) when nil. The tests give
// a fake that follows the redirect.
Browser oauth.Opener
// OAuthTimeout is how long "Get New Access Token" waits for the user; oauth.DefaultTimeout when 0.
OAuthTimeout time.Duration
}
Options are the parts of the extension a test or the host replaces.
Source Files
¶
- collections.go
- commands.go
- dev.go
- devecho.go
- doc.go
- environments.go
- envtab.go
- extension.go
- extraction.go
- historyview.go
- oauthtoken.go
- remote.go
- reqdraft.go
- reqhighlight.go
- reqoauth.go
- reqrules.go
- reqsecrets.go
- reqsend.go
- reqsync.go
- reqtab.go
- requests.go
- reqview.go
- respactions.go
- respchecks.go
- respdisplay.go
- respview.go
- runner.go
- runreport.go
- runtab.go
- runview.go
- viewkit.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package checks reads a response of the HTTP client: it takes values out of it for extraction rules and tests it with checks (SPEC §10.33 "Extraction and checks").
|
Package checks reads a response of the HTTP client: it takes values out of it for extraction rules and tests it with checks (SPEC §10.33 "Extraction and checks"). |
|
Package engine sends the requests of the HTTP client and captures everything about the response (SPEC §10.33 "The engine").
|
Package engine sends the requests of the HTTP client and captures everything about the response (SPEC §10.33 "The engine"). |
|
Package format is the file format of the HTTP client, version 1 (SPEC §10.33 "The format"): the types of a collection, a folder, a request and an environment, reading them from text with comments, and writing them.
|
Package format is the file format of the HTTP client, version 1 (SPEC §10.33 "The format"): the types of a collection, a folder, a request and an environment, reading them from text with comments, and writing them. |
|
Package history is the history of the requests the HTTP client sent in a workspace (SPEC §10.33 "The side bar", "As built (step 27.3)"): the last httpClient.historyLimit of them with the method, the URL, the status and the time, and a copy of the request with its secrets and authorization values masked.
|
Package history is the history of the requests the HTTP client sent in a workspace (SPEC §10.33 "The side bar", "As built (step 27.3)"): the last httpClient.historyLimit of them with the method, the URL, the status and the time, and a copy of the request with its secrets and authorization values masked. |
|
Package jsonpath is the small JSONPath of the HTTP client's extraction rules and checks (SPEC §10.33 "Extraction and checks"): an evaluator of our own over the values encoding/json decodes, standard library only.
|
Package jsonpath is the small JSONPath of the HTTP client's extraction rules and checks (SPEC §10.33 "Extraction and checks"): an evaluator of our own over the values encoding/json decodes, standard library only. |
|
Package oauth gets, keeps and refreshes the OAuth 2.0 tokens of the HTTP client (SPEC §10.33 "OAuth 2.0"): the client credentials grant (RFC 6749 §4.4) and the authorization code grant (§4.1) with PKCE (RFC 7636, S256), whose code arrives on a loopback redirect (RFC 8252 §7.3) that exists only while it waits.
|
Package oauth gets, keeps and refreshes the OAuth 2.0 tokens of the HTTP client (SPEC §10.33 "OAuth 2.0"): the client credentials grant (RFC 6749 §4.4) and the authorization code grant (§4.1) with PKCE (RFC 7636, S256), whose code arrives on a loopback redirect (RFC 8252 §7.3) that exists only while it waits. |
|
fakeas
Package fakeas is a small OAuth 2.0 authorization server on 127.0.0.1 for the tests of the HTTP client and for its dev proof (SPEC §15.2).
|
Package fakeas is a small OAuth 2.0 authorization server on 127.0.0.1 for the tests of the HTTP client and for its dev proof (SPEC §15.2). |
|
Package rundata reads the data files of the collection runner (SPEC §10.33 "The collection runner"): a CSV file with a header row, or a JSON array of objects.
|
Package rundata reads the data files of the collection runner (SPEC §10.33 "The collection runner"): a CSV file with a header row, or a JSON array of objects. |
|
Package store keeps the tree of the collections and environments of a workspace (SPEC §10.33): it reads the files of <folder>/.emetos/http with package format, follows the changes made on disk (an editor, git pull) through the workspace watcher, and makes the changes the side bar asks for (create, rename, move, duplicate, delete to the trash) as edits of the files that keep the comments and the keys a user added.
|
Package store keeps the tree of the collections and environments of a workspace (SPEC §10.33): it reads the files of <folder>/.emetos/http with package format, follows the changes made on disk (an editor, git pull) through the workspace watcher, and makes the changes the side bar asks for (create, rename, move, duplicate, delete to the trash) as edits of the files that keep the comments and the keys a user added. |
|
Package variables resolves the {{name}} of the HTTP client (SPEC §10.33 "Variables"): the order in which the places that define a name are looked at, the dynamic variables ({{$guid}}, {{$processEnv NAME}}), the current values that only this computer has (kept in Emetos's state, never in the project), the globals of the user, and the secrets, which are in the desktop keyring and never in a file (D45).
|
Package variables resolves the {{name}} of the HTTP client (SPEC §10.33 "Variables"): the order in which the places that define a name are looked at, the dynamic variables ({{$guid}}, {{$processEnv NAME}}), the current values that only this computer has (kept in Emetos's state, never in the project), the globals of the user, and the secrets, which are in the desktop keyring and never in a file (D45). |