Documentation
¶
Overview ¶
Package toolplugin is the plugin side of tool plugins: ServeTool turns an ordinary tool.Module (the same Register func a built-in tool uses) into a binary that serves HTTP on the unix socket the host names, while the host reverse-proxies /tools/{key}/* to it and wraps page fragments in wick's layout.
It lives apart from pkg/plugin so connector binaries, which import pkg/plugin, do not link pkg/tool and its templ render stack.
Index ¶
- func Handler(mod tool.Module, cfg map[string]string) http.Handler
- func Host(ctx context.Context) (host.Host, error)
- func Manifest(mod tool.Module, opts ...Option) wickplugin.ToolModule
- func ServeTool(mod tool.Module, opts ...Option)
- func TokenUserFromHeaders(r *http.Request) (tool.User, bool)
- func UserFromHeaders(r *http.Request) (tool.User, bool)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
Handler returns the plugin's HTTP handler for mod without serving it — for tests and local harnesses. cfg seeds the config store.
func Host ¶ added in v1.16.0
Host returns wick's Host API for this tool plugin (see wickplugin.Host). Pass the request context so user-level calls run for the person behind the request; host.ErrHostAPIUnavailable means an older wick.
func Manifest ¶
func Manifest(mod tool.Module, opts ...Option) wickplugin.ToolModule
Manifest returns the tool half of mod's manifest (routes are registered to discover the webhooks).
func ServeTool ¶
ServeTool is the entire main() of a tool plugin binary. With --dump-manifest it prints the kind=tool manifest and exits; otherwise it serves HTTP on $WICK_PLUGIN_SOCKET plus the Tool control service until the host kills it.
func TokenUserFromHeaders ¶ added in v1.16.0
TokenUserFromHeaders reads who a webhook request authenticated as, as the host verified and injected it: the owner of a wick PAT, a user behind wick's SSO JWT, or wick itself (ID tool.SystemUserID). User.Source says which; a host too old to send the source header only injected PAT owners, so an absent source reads as tool.TokenSourcePAT. ok is false when the request carried no credential the host could verify.