Documentation
¶
Overview ¶
Package webserver serves the local web API behind `workflow --web`: the same information the terminal interface shows, and the configuration file, over the REST surface described by api/openapi.yaml. It reuses the domain seams the TUI and the CLI already use — it is another consumer of the wiring, not a second implementation — so each write it makes, to the repository, the forge, the tracker, the messaging service or the configuration file, goes through the seam the terminal's own goes through.
Index ¶
Constants ¶
const DefaultPort = 13579
DefaultPort is the port the server listens on when `workflow --web` is given no --port. IANA assigns 13579 to no service, and it sits below the range Linux, macOS and Windows hand out to outgoing connections, so another program is unlikely to hold it.
const HereHeader = "Workflow-Here"
HereHeader is the header a page sends on a write naming the directory it shows, escaped as a URL path is, so a write from a page that has not noticed a switch is refused rather than made in the directory switched to.
Variables ¶
var ( // ErrConfigurationRefused is a directory whose configuration the // interface would refuse to start on, which a switch is refused for. ErrConfigurationRefused = errors.New("the configuration there binds keys workflow refuses") // ErrConfigurationUnreadable is a directory whose configuration did not // load, which a switch is refused for rather than serve the defaults. ErrConfigurationUnreadable = errors.New("the configuration there did not load") )
Functions ¶
func Handler ¶
func Handler(ctx context.Context, first World, assets fs.FS, session edge.Session) (http.Handler, error)
Handler builds the http.Handler that serves the web interface for first, the directory it starts in: the API, behind the request boundary (internal/webserver/edge), which admits only a request presenting session, with the embedded single-page app, assets, under every other path. The server starts from the configuration file at first.Config.Path as startingPoint reads it, not from that configuration alone, which the process read a moment before. It fails when that file cannot be read, or when the embedded spec cannot be loaded or routed, which is a build defect. ctx is the server's lifetime: a read ends when its page goes, but a write goes on to its end and ends only with ctx.
func LoopbackAddr ¶
LoopbackAddr is where the server listens in production, on port: the loopback interface only, so the API is reachable from this machine and nowhere else.
Types ¶
type Deps ¶
type Deps struct {
Jira seams.Jira
Git seams.Git
Forge seams.Forge
Messaging seams.Messaging
Hooks seams.Hooks
Store seams.Store
// Tasks is what the server asks of Taskwarrior. A nil Install, or one that
// fails, answers the task list and the snapshot's summary as not available —
// never a 404 — and a write with a nil function is refused as unprocessable.
Tasks seams.Tasks
// Repositories is where the server works and any other directory read the
// same way, and your home directory, which Taskwarrior's words can name
// and an answer shows as ~; none leaves them naming it.
Repositories seams.Repositories
// Settings lists and removes the local data, and sets up a first
// configuration file where none applies; Settings offers that only where
// its Setup.Write is wired. The server keeps its own read of the
// configuration, for its ETag, so it never calls Read or Save.
Settings seams.Settings
// Clock tells the time, for when the event stream last asked the forge.
// Nil means the system clock.
Clock func() time.Time
// CheckKeys says why the terminal interface would refuse a ui.keys map,
// or nil where it would start on it. Nil here means no map is checked.
CheckKeys func(keys map[string]string) error
// KeyActions is every action the terminal interface's help lists, with a
// ui.keys map applied, its review noun and its messaging service naming
// what the help names for them: the keys a page binds, read from the
// terminal's own bindings. Nil lists none.
KeyActions func(reviewNoun, messagingService string, overrides map[string]string) []seams.KeyAction
// PaneSections is the page's section each of the terminal interface's
// panes is shown in, in the panes' order, as the interface's key check
// reads it. Nil lists none.
PaneSections func() []seams.PageSection
// Unexpected hears each failure the server answers as an internal error —
// one no class of failure explains, or an answer that could not be
// written — whose cause the answer leaves out, with the configuration in
// effect when it failed: a credential taken up since the server started,
// from a switch or a save in Settings, is that configuration's. Nil says
// nothing.
Unexpected func(inEffect config.Config, err error)
// UseForgeSettings applies forge settings just saved to every forge call
// after the save, and reports which forge the remote is on under them, so a
// token, host or kind saved in Settings needs no restart. Nil leaves the
// forge as it was started.
UseForgeSettings func(settings config.Forge) forge.Kind
// UseMessagingSettings applies messaging settings just saved to every post
// after the save. Nil leaves messaging as it was started.
UseMessagingSettings func(settings config.Messaging)
// PlaceSlackCredentials keeps a Slack user token's secrets, typed into
// Settings, where the configuration keeps them — refreshing the token once
// and saving the pair to the macOS keychain, and answering the
// configuration without them, or answering it unchanged where the file is
// where they are kept. Nil writes them into the file as they came.
PlaceSlackCredentials func(ctx context.Context, cfg config.Config) (config.Config, error)
// KeepJiraToken keeps a Jira token typed into Settings in the macOS
// keychain, under the item for its address, so the file saved reads it
// from there. Nil writes it into the file as it came.
KeepJiraToken func(ctx context.Context, service, secret string) error
// Reach wires another directory as this one was wired, for a switch; nil
// where switching is not offered. A setup takes the file up through it,
// where the server works.
Reach func(ctx context.Context, dir string) (World, error)
}
Deps is what the server asks of the world: the seam groups internal/seams declares, as the terminal interface takes them, and the few the server alone asks for. A nil function means the service is not configured. A list or snapshot read then answers empty; the issue read answers 422, as no issue tracker is configured; a write whose own seam is nil answers 422, as not available; and the announcement and pull request drafts, and the announce and open writes past that check, answer 409, as there is nothing to announce or open, when the branch read or the pull request find is missing.
type Info ¶
type Info struct {
Version string
DryRun bool
// ForgeKind is the forge the remote points at, resolved from the git remote
// as the interface resolves it, so the announcement and the browser name a
// "merge request" on GitLab and a "pull request" elsewhere — the health read
// carries the words and the sigil to the page. The raw config kind is unset
// for self-identifying hosts (gitlab.com), so it cannot answer this.
ForgeKind forge.Kind
// Repository names the repository the server runs in, as its forge path
// or its directory, for the groups Settings keeps for it.
Repository string
// StreamInterval is how often the event stream re-pushes a snapshot. A zero
// or negative value takes defaultStreamInterval.
StreamInterval time.Duration
// Taskwarrior is the taskwarrior settings Deps.Tasks was bound with when
// workflow started in or switched to this directory. A change saved since
// applies at the next start or directory switch, so while the settings in
// effect differ the task list says so rather than a reason the new
// settings would not give.
Taskwarrior config.Taskwarrior
}
Info is the build and run facts the API reports and the server needs.
Source Files
¶
- activity.go
- announce.go
- announcearm.go
- announcememory.go
- announcequeue.go
- announcetags.go
- branchcreate.go
- branchlink.go
- checkout.go
- commit.go
- config.go
- dto.go
- faults.go
- handlers.go
- issuecache.go
- issuewrite.go
- localdata.go
- people.go
- pullrequest.go
- push.go
- repogroups.go
- repositories.go
- reviewwrites.go
- setup.go
- slackdirectory.go
- staging.go
- stream.go
- streamcache.go
- webserver.go
- world.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package edge is the request boundary of `workflow --web`: what every request passes before the server's own handlers take it.
|
Package edge is the request boundary of `workflow --web`: what every request passes before the server's own handlers take it. |
|
Package problem is the RFC 9457 problem details the --web API answers a failure with: the status, title and type each code fixes, the default answer a strict handler returns with one, and one written by the hand-written middleware that answers before a strict handler runs.
|
Package problem is the RFC 9457 problem details the --web API answers a failure with: the status, title and type each code fixes, the default answer a strict handler returns with one, and one written by the hand-written middleware that answers before a strict handler runs. |
|
Package runs serves the git runs of `workflow --web` and lefthook's hooks: POST /api/runs, which starts a hook, a rebase, an amend or a fixup and streams it while it goes, DELETE /api/runs/current, which stops it, and the hooks lefthook configures and the offer to set it up.
|
Package runs serves the git runs of `workflow --web` and lefthook's hooks: POST /api/runs, which starts a hook, a rebase, an amend or a fixup and streams it while it goes, DELETE /api/runs/current, which stops it, and the hooks lefthook configures and the offer to set it up. |
|
Package tasks serves the Taskwarrior operations of the web API behind `workflow --web`: the task list, the event stream's summary of your tasks, and the writes on them, over the seam the terminal's Tasks pane asks.
|
Package tasks serves the Taskwarrior operations of the web API behind `workflow --web`: the task list, the event stream's summary of your tasks, and the writes on them, over the seam the terminal's Tasks pane asks. |
|
Package webtest is what the tests of internal/webserver and of the packages that leave it share: the harness that serves the API handler under a session and sends it requests, the canned seams and fixture constants, the event stream's reader, a seam call held on its context, the configuration's edits, the Taskwarrior fake and lefthook's fixtures.
|
Package webtest is what the tests of internal/webserver and of the packages that leave it share: the harness that serves the API handler under a session and sends it requests, the canned seams and fixture constants, the event stream's reader, a seam call held on its context, the configuration's edits, the Taskwarrior fake and lefthook's fixtures. |