Documentation
¶
Overview ¶
Package shortcut exposes the /api/v1/shortcut HTTP endpoints that let the frontend create (or check for) the desktop / start-menu shortcut the CLI's `tingly-box shortcut` command already writes. All actual file-writing logic lives in internal/shortcut, which has no HTTP or CLI dependency — this package only adapts it to gin, mirroring the "future HTTP handler" sketch in .design/shortcut.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
func RegisterRoutes(apiV1 *swagger.RouteGroup, h *Handler)
RegisterRoutes wires the /shortcut endpoints onto an authenticated route group.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler carries the minimal server state needed to serve /api/v1/shortcut. launchSource and version are known once, at boot, from how this process itself was started (see internal/command's --source flag); they are never persisted, matching the CLI's own "no detection, no persistence" design.
func NewHandler ¶
NewHandler creates a Handler.
func (*Handler) Create ¶
Create handles POST /api/v1/shortcut: (re)writes the desktop / start-menu shortcut(s) and the Linux headless launcher script, and returns the real paths written. Deliberately zero-config beyond an optional display name — no --no-desktop/--no-menu equivalent — and idempotent, so the frontend can let the user click it again any time (after an upgrade, a source change, or just to recover a deleted shortcut) without needing to track state.
type ShortcutCreateRequest ¶
type ShortcutCreateRequest struct {
Name string `json:"name,omitempty" example:"Tingly Box"`
}
ShortcutCreateRequest is the JSON body for POST /api/v1/shortcut. Empty is a valid request — Name defaults to "Tingly Box" and both desktop/menu artifacts are always written (no --no-desktop/--no-menu equivalent exposed here: the CLI flags exist for scripting, but the UI has one zero-config action). Named with the module's own prefix, not the generic "CreateRequest" — swagger's model registry keys schemas by Go type name, and several other modules (team, imbot) already have their own CreateRequest, so a bare name here would silently collide with one of theirs in the generated schema.
type ShortcutCreateResponse ¶
type ShortcutCreateResponse struct {
Success bool `json:"success" example:"true"`
Error string `json:"error,omitempty"`
Data ShortcutInfo `json:"data,omitempty"`
}
ShortcutCreateResponse is the JSON envelope for POST /api/v1/shortcut.
type ShortcutInfo ¶
type ShortcutInfo struct {
// Created lists every path written (or, for status, that already exists),
// e.g. ["/home/user/Desktop/tingly-box.desktop", "/home/user/.local/bin/tingly-box.sh"].
Created []string `json:"created"`
// ScriptPath is the headless launcher script's path (Linux-only), or ""
// when none was written/found — lets the frontend swap "double-click" for
// "run this command" without re-deriving platform logic.
ScriptPath string `json:"script_path,omitempty" example:"/home/user/.local/bin/tingly-box.sh"`
}
ShortcutInfo describes the outcome of a create (or status) call.
type ShortcutStatusResponse ¶
type ShortcutStatusResponse struct {
Success bool `json:"success" example:"true"`
Data ShortcutInfo `json:"data"`
Exists bool `json:"exists" example:"false"`
}
ShortcutStatusResponse is the JSON envelope for GET /api/v1/shortcut. Exists is true only when every artifact this platform would write is already present on disk (a partial/stale set still reads as "not created" — the Create action rewrites everything in one pass anyway). Named with the module's own prefix for the same reason as ShortcutCreateRequest — a bare "StatusResponse" already collides with internal/server's own type.