Documentation
¶
Overview ¶
Package attachhttp exposes prompt resource attachments (#1013) over REST for both operator surfaces: the portal (a prompt author manages the materials on their own prompts) and the admin API (any prompt). It lives beside pkg/prompt rather than inside pkg/portal or pkg/admin so those packages stay within the package-size budget; the composition root mounts it under each surface's path prefix wrapped in that surface's own authentication middleware and injects the identity accessors, so this package never imports either surface.
The scope rule is enforced here at attach time, not only at serve time. The serve-time check protects the reader; this one protects the author, who would otherwise learn that a shared SOP has unreachable materials only from someone else's failed run.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttachmentView ¶
type AttachmentView struct {
ResourceID string `json:"resource_id"`
Position int `json:"position"`
AttachedBy string `json:"attached_by,omitempty"`
DisplayName string `json:"display_name,omitempty"`
Description string `json:"description,omitempty"`
Category string `json:"category,omitempty"`
MIMEType string `json:"mime_type,omitempty"`
SizeBytes int64 `json:"size_bytes,omitempty"`
URI string `json:"uri,omitempty"`
Scope string `json:"scope,omitempty"`
ScopeID string `json:"scope_id,omitempty"`
// Broken marks an attachment whose resource was deleted. The row stays in
// the list so an author can see and remove the dangling link; without it a
// deleted template would simply vanish from the editor while the served
// prompt kept reporting a missing material.
Broken bool `json:"broken,omitempty"`
// Unreadable marks an attachment that exists but that this caller cannot
// read. It carries the position (so the row renders in place) and nothing
// else about the resource or its attacher, for the same reason the serving
// path withholds them.
Unreadable bool `json:"unreadable,omitempty"`
}
AttachmentView is one attachment as the portal renders it: the link plus enough of the resource to show a row, and a broken flag when the resource behind the link no longer exists.
type Deps ¶
type Deps struct {
Store prompt.Store
Attachments prompt.AttachmentStore
Resources resource.Store
// Caller resolves the authenticated caller's permission claims, or nil when
// the request carries no user. Injected per surface by the composition root.
Caller func(r *http.Request) *Identity
}
Deps carries the collaborators the attachment handlers need. Every field except Caller is required; a nil Store, Attachments, or Resources leaves the routes unmounted rather than serving a half-working surface.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the prompt attachment routes.
func New ¶
New builds the handler. It returns nil when a required collaborator is missing, so the composition root can skip mounting without a second check.