handlers

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Overview

Package handlers provides HTTP handlers for the AppView web UI, including home page, repository browsing, search, user authentication, settings, device management, and API endpoints for the web interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchSbomDetails

func FetchSbomDetails(ctx context.Context, holdEndpoint, digest string) sbomDetailsData

FetchSbomDetails fetches SBOM data for a digest from a hold. holdEndpoint should be the hold DID.

func FetchVulnDetails

func FetchVulnDetails(ctx context.Context, holdEndpoint, digest string) vulnDetailsData

FetchVulnDetails fetches vulnerability scan details for a digest from a hold. This is the shared logic used by both VulnDetailsHandler and DigestDetailHandler. holdEndpoint should already be resolved (successor-aware) before calling this.

func RenderHTMXError added in v0.1.3

func RenderHTMXError(w http.ResponseWriter, r *http.Request, status int, userMsg string, serverErr error)

RenderHTMXError sends an error response suitable for htmx. For htmx requests it sets an HX-Trigger header so the client fires a toast event; the JS fallback in app.js will show a generic toast even without the header. For non-htmx requests it falls back to http.Error. serverErr is logged but never exposed to the user — pass userMsg for anything screen-readable.

func RenderNotFound

func RenderNotFound(w http.ResponseWriter, r *http.Request, h *BaseUIHandler)

RenderNotFound renders the 404 page template. Use this from other handlers when a resource is not found.

func TrimRegistryURL

func TrimRegistryURL(url string) string

TrimRegistryURL removes http:// or https:// prefix from a URL for use in Docker commands where only the host:port is needed

Types

type AddWebhookHandler

type AddWebhookHandler struct {
	BaseUIHandler
}

AddWebhookHandler handles adding a new webhook via form POST

func (*AddWebhookHandler) ServeHTTP

func (h *AddWebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type AttestationDetailsHandler

type AttestationDetailsHandler struct {
	BaseUIHandler
}

AttestationDetailsHandler handles requests for attestation detail modal content. Returns an HTML fragment (attestation-details partial) for insertion into the modal body.

func (*AttestationDetailsHandler) ServeHTTP

type BaseUIHandler

type BaseUIHandler struct {
	// Display
	Templates   *template.Template
	RegistryURL string // Docker registry domain (e.g., "buoy.cr" or "atcr.io")
	SiteURL     string // Website domain (e.g., "seamark.dev" or "atcr.io")

	// Database (handlers choose which to use)
	DB         *sql.DB // Write access
	ReadOnlyDB *sql.DB // Read-only access

	// Services
	Refresher         *oauth.Refresher
	HealthChecker     *holdhealth.Checker
	ReadmeFetcher     *readme.Fetcher
	Directory         identity.Directory
	BillingManager    *billing.Manager
	WebhookDispatcher *webhooks.Dispatcher
	OAuthClientApp    *indigooauth.ClientApp

	// Stores
	SessionStore *db.SessionStore
	DeviceStore  *db.DeviceStore
	OAuthStore   *db.OAuthStore

	// Config
	DefaultHoldDID   string
	CompanyName      string
	Jurisdiction     string
	ClientName       string // Full name: "AT Container Registry"
	ClientShortName  string // Short name: "ATCR"
	AIAdvisorEnabled bool   // True when Claude API key is configured
	SourceURL        string // Source code URL for the footer "Source" link
}

BaseUIHandler contains all dependencies for UI handlers. Handlers embed this and use whatever fields they need. Route registration becomes simply &Handler{base} for everything.

type BatchScanResultHandler

type BatchScanResultHandler struct {
	BaseUIHandler
}

BatchScanResultHandler handles a single HTMX request that fetches scan results for multiple manifests concurrently and returns OOB swap fragments.

func (*BatchScanResultHandler) ServeHTTP

type DefaultOGHandler

type DefaultOGHandler struct {
	BaseUIHandler
}

DefaultOGHandler generates the default OpenGraph image for the home page

func (*DefaultOGHandler) ServeHTTP

func (h *DefaultOGHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DeleteAccountHandler

type DeleteAccountHandler struct {
	BaseUIHandler
}

DeleteAccountHandler handles GDPR account deletion requests

func (*DeleteAccountHandler) ServeHTTP

func (h *DeleteAccountHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DeleteAccountRequest

type DeleteAccountRequest struct {
	DeletePDSRecords bool   `json:"delete_pds_records"`
	Confirmation     string `json:"confirmation"` // Must be "DELETE <handle>" to confirm
}

DeleteAccountRequest represents the GDPR account deletion request

type DeleteAccountResponse

type DeleteAccountResponse struct {
	Success        bool               `json:"success"`
	AppViewDeleted bool               `json:"appview_deleted"`
	PDSDeleted     bool               `json:"pds_deleted,omitempty"`
	PDSCollections map[string]int     `json:"pds_collections_deleted,omitempty"`
	HoldResults    []HoldDeleteResult `json:"hold_results"`
	Errors         []string           `json:"errors,omitempty"`
}

DeleteAccountResponse represents the result of account deletion

type DeleteManifestHandler

type DeleteManifestHandler struct {
	BaseUIHandler
}

DeleteManifestHandler handles deleting a manifest

func (*DeleteManifestHandler) ServeHTTP

type DeleteTagHandler

type DeleteTagHandler struct {
	BaseUIHandler
}

DeleteTagHandler handles deleting a tag

func (*DeleteTagHandler) ServeHTTP

func (h *DeleteTagHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DeleteUntaggedManifestsHandler

type DeleteUntaggedManifestsHandler struct {
	BaseUIHandler
}

DeleteUntaggedManifestsHandler handles bulk-deleting all untagged manifests in a repository

func (*DeleteUntaggedManifestsHandler) ServeHTTP

type DeleteWebhookHandler

type DeleteWebhookHandler struct {
	BaseUIHandler
}

DeleteWebhookHandler handles deleting a webhook

func (*DeleteWebhookHandler) ServeHTTP

func (h *DeleteWebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DeviceApprovalPageHandler

type DeviceApprovalPageHandler struct {
	BaseUIHandler
}

DeviceApprovalPageHandler handles GET /device

func (*DeviceApprovalPageHandler) ServeHTTP

type DeviceApproveHandler

type DeviceApproveHandler struct {
	BaseUIHandler
}

DeviceApproveHandler handles POST /device/approve

func (*DeviceApproveHandler) ServeHTTP

func (h *DeviceApproveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DeviceApproveRequest

type DeviceApproveRequest struct {
	UserCode string `json:"user_code"`
	Approve  bool   `json:"approve"`
}

DeviceApproveRequest is the request to approve a device

type DeviceCodeHandler

type DeviceCodeHandler struct {
	BaseUIHandler
	AppViewBaseURL string // e.g., "http://localhost:5000"
}

DeviceCodeHandler handles POST /auth/device/code

func (*DeviceCodeHandler) ServeHTTP

func (h *DeviceCodeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DeviceCodeRequest

type DeviceCodeRequest struct {
	DeviceName string `json:"device_name"`
}

DeviceCodeRequest is the request to start device authorization

type DeviceCodeResponse

type DeviceCodeResponse struct {
	DeviceCode      string `json:"device_code"`
	UserCode        string `json:"user_code"`
	VerificationURI string `json:"verification_uri"`
	ExpiresIn       int    `json:"expires_in"`
	Interval        int    `json:"interval"`
}

DeviceCodeResponse is the response with user and device codes

type DeviceTokenHandler

type DeviceTokenHandler struct {
	BaseUIHandler
}

DeviceTokenHandler handles POST /auth/device/token

func (*DeviceTokenHandler) ServeHTTP

func (h *DeviceTokenHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DeviceTokenRequest

type DeviceTokenRequest struct {
	DeviceCode string `json:"device_code"`
}

DeviceTokenRequest is the request to poll for device authorization

type DeviceTokenResponse

type DeviceTokenResponse struct {
	DeviceSecret string `json:"device_secret,omitempty"`
	Handle       string `json:"handle,omitempty"`
	DID          string `json:"did,omitempty"`
	Error        string `json:"error,omitempty"`
}

DeviceTokenResponse is the response with device secret or error

type DiffSummary

type DiffSummary struct {
	SizeDelta      int64 // bytes, positive = "to" is larger
	LayerCountFrom int
	LayerCountTo   int
	VulnFixedCount int
	VulnNewCount   int
	VulnFixedBySev vulnSummary
	VulnNewBySev   vulnSummary
	HasVulnData    bool
}

DiffSummary is the top-line summary for the banner and diff page.

type DigestContentHandler

type DigestContentHandler struct {
	BaseUIHandler
}

DigestContentHandler returns the layers + vulnerabilities HTML fragment for a specific platform manifest. Used by the arch dropdown via HTMX.

func (*DigestContentHandler) ServeHTTP

func (h *DigestContentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DigestDetailHandler

type DigestDetailHandler struct {
	BaseUIHandler
}

DigestDetailHandler renders the digest detail page with layers + vulnerabilities.

func (*DigestDetailHandler) ServeHTTP

func (h *DigestDetailHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ExportUserDataHandler

type ExportUserDataHandler struct {
	BaseUIHandler
}

ExportUserDataHandler handles GDPR data export requests

func (*ExportUserDataHandler) ServeHTTP

type FullUserDataExport

type FullUserDataExport struct {
	AppViewData *db.UserDataExport `json:"appview_data"`
	HoldExports []HoldExportResult `json:"hold_exports"`
}

FullUserDataExport represents the complete GDPR export including hold data

type HelmChartContent added in v0.1.3

type HelmChartContent struct {
	Meta            *holdclient.HelmChartMeta
	Tarball         *LayerDetail
	MetaFetchFailed bool // hold reachable but config blob couldn't be parsed
	HoldUnreachable bool
}

HelmChartContent is the data the helm-aware digest content needs: parsed Chart.yaml metadata + a single chart-tarball "layer" pulled from the DB.

type HoldDeleteResult

type HoldDeleteResult struct {
	HoldDID       string `json:"hold_did"`
	Relationship  string `json:"relationship"` // "captain" or "crew_member"
	Status        string `json:"status"`       // "success", "failed", "offline"
	Error         string `json:"error,omitempty"`
	CrewDeleted   bool   `json:"crew_deleted,omitempty"`
	LayersDeleted int    `json:"layers_deleted,omitempty"`
	StatsDeleted  int    `json:"stats_deleted,omitempty"`
	PostsDeleted  int    `json:"posts_deleted,omitempty"`
}

HoldDeleteResult represents the result of deleting data from a single hold

type HoldDisplay

type HoldDisplay struct {
	DID         string   `json:"did"`
	DisplayName string   `json:"displayName"`
	Region      string   `json:"region"`
	Membership  string   `json:"membership"`
	Permissions []string `json:"permissions,omitempty"`
	Status      string   `json:"status"` // "" = unknown, "online", "offline"
	IsActive    bool     `json:"isActive"`
}

HoldDisplay represents a hold for display in the UI

type HoldExportResult

type HoldExportResult struct {
	HoldDID      string          `json:"hold_did"`
	Endpoint     string          `json:"endpoint"`
	Relationship string          `json:"relationship"` // "captain", "crew_member"
	FirstSeen    time.Time       `json:"first_seen"`
	Status       string          `json:"status"` // "success", "failed", "offline"
	Error        string          `json:"error,omitempty"`
	Data         json.RawMessage `json:"data,omitempty"` // Raw JSON from hold
}

HoldExportResult represents the result of fetching export from a hold

type HomeHandler

type HomeHandler struct {
	BaseUIHandler
}

HomeHandler handles the home page

func (*HomeHandler) ServeHTTP

func (h *HomeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ImageAdvisorHandler

type ImageAdvisorHandler struct {
	BaseUIHandler
	ClaudeAPIKey string
}

ImageAdvisorHandler returns AI-powered suggestions for improving a container image. Returns an HTML fragment (image-advisor-results partial) via HTMX.

func (*ImageAdvisorHandler) ServeHTTP

func (h *ImageAdvisorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type InstallHandler

type InstallHandler struct {
	BaseUIHandler
}

InstallHandler handles the /install page

func (*InstallHandler) ServeHTTP

func (h *InstallHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type JSONLDEntryPoint

type JSONLDEntryPoint struct {
	Type        string `json:"@type"`
	URLTemplate string `json:"urlTemplate"`
}

JSONLDEntryPoint represents a schema.org EntryPoint for search.

type JSONLDOrg

type JSONLDOrg struct {
	Type string `json:"@type"`
	Name string `json:"name"`
	URL  string `json:"url,omitempty"`
}

JSONLDOrg represents a schema.org Organization (minimal version for embedding).

type JSONLDOrganization

type JSONLDOrganization struct {
	Context       string   `json:"@context"`
	Type          string   `json:"@type"`
	Name          string   `json:"name"`
	AlternateName string   `json:"alternateName,omitempty"`
	URL           string   `json:"url"`
	Description   string   `json:"description,omitempty"`
	SameAs        []string `json:"sameAs,omitempty"`
}

JSONLDOrganization represents a schema.org Organization.

func NewJSONLDOrganization

func NewJSONLDOrganization(registryURL, shortName, fullName string) JSONLDOrganization

NewJSONLDOrganization creates an Organization object for the registry. shortName is the brand name (e.g., "ATCR"), fullName is the full name (e.g., "AT Container Registry").

type JSONLDPerson

type JSONLDPerson struct {
	Type  string `json:"@type"`
	Name  string `json:"name"`
	URL   string `json:"url,omitempty"`
	Image string `json:"image,omitempty"`
}

JSONLDPerson represents a schema.org Person.

type JSONLDProfilePage

type JSONLDProfilePage struct {
	Context    string        `json:"@context"`
	Type       string        `json:"@type"`
	MainEntity *JSONLDPerson `json:"mainEntity"`
}

JSONLDProfilePage represents a schema.org ProfilePage.

func NewJSONLDProfilePage

func NewJSONLDProfilePage(registryURL, handle, avatar string) JSONLDProfilePage

NewJSONLDProfilePage creates a ProfilePage object for a user.

type JSONLDSearchAction

type JSONLDSearchAction struct {
	Type       string            `json:"@type"`
	Target     *JSONLDEntryPoint `json:"target"`
	QueryInput string            `json:"query-input"`
}

JSONLDSearchAction represents a schema.org SearchAction.

type JSONLDSoftwareSourceCode

type JSONLDSoftwareSourceCode struct {
	Context        string        `json:"@context"`
	Type           string        `json:"@type"`
	Name           string        `json:"name"`
	Description    string        `json:"description"`
	CodeRepository string        `json:"codeRepository"`
	Author         *JSONLDPerson `json:"author,omitempty"`
	Publisher      *JSONLDOrg    `json:"publisher,omitempty"`
	License        string        `json:"license,omitempty"`
	IsBasedOn      string        `json:"isBasedOn,omitempty"`
}

JSONLDSoftwareSourceCode represents a schema.org SoftwareSourceCode (for repositories).

func NewJSONLDSoftwareSourceCode

func NewJSONLDSoftwareSourceCode(registryURL, handle, repoName, description, license, sourceURL, shortName string) JSONLDSoftwareSourceCode

NewJSONLDSoftwareSourceCode creates a SoftwareSourceCode object for a repository. shortName is the brand name (e.g., "ATCR").

type JSONLDWebSite

type JSONLDWebSite struct {
	Context         string              `json:"@context"`
	Type            string              `json:"@type"`
	Name            string              `json:"name"`
	URL             string              `json:"url"`
	PotentialAction *JSONLDSearchAction `json:"potentialAction,omitempty"`
}

JSONLDWebSite represents a schema.org WebSite with search action.

func NewJSONLDWebSite

func NewJSONLDWebSite(registryURL, shortName string) JSONLDWebSite

NewJSONLDWebSite creates a WebSite object with search action. shortName is the brand name (e.g., "ATCR").

type LayerDetail

type LayerDetail struct {
	Index      int
	Command    string // Dockerfile command (from config history)
	Digest     string
	Size       int64
	MediaType  string
	EmptyLayer bool // ENV, LABEL, etc. — no actual layer blob
}

LayerDetail combines OCI config history with layer metadata from the DB.

type LayerDiffEntry

type LayerDiffEntry struct {
	Status    string       // "shared", "rebuilt", "added", "removed"
	Layer     LayerDetail  // the "to" layer (or from-layer for "removed")
	PrevLayer *LayerDetail // set for "rebuilt" — the old layer
}

LayerDiffEntry represents one row in the layer diff table.

type LearnMoreHandler

type LearnMoreHandler struct {
	BaseUIHandler
}

LearnMoreHandler handles the /learn-more page

func (*LearnMoreHandler) ServeHTTP

func (h *LearnMoreHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type LegalPageData

type LegalPageData struct {
	PageData
	Meta         *PageMeta
	CompanyName  string
	Jurisdiction string
	LastUpdated  string
}

LegalPageData contains data for legal pages (terms, privacy).

type ListDevicesHandler

type ListDevicesHandler struct {
	BaseUIHandler
}

ListDevicesHandler handles GET /api/devices Returns HTML partial for HTMX requests, JSON for API requests

func (*ListDevicesHandler) ServeHTTP

func (h *ListDevicesHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type LoginHandler

type LoginHandler struct {
	BaseUIHandler
}

LoginHandler shows the OAuth login form

func (*LoginHandler) ServeHTTP

func (h *LoginHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type LoginSubmitHandler

type LoginSubmitHandler struct {
	BaseUIHandler
}

LoginSubmitHandler processes the login form submission

func (*LoginSubmitHandler) ServeHTTP

func (h *LoginSubmitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type LogoutHandler

type LogoutHandler struct {
	BaseUIHandler
}

LogoutHandler handles user logout from the web UI This only clears the current UI session cookie - it does NOT revoke OAuth tokens OAuth sessions remain intact so other browser tabs/devices stay logged in

func (*LogoutHandler) ServeHTTP

func (h *LogoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ManifestDiffHandler

type ManifestDiffHandler struct {
	BaseUIHandler
}

ManifestDiffHandler renders the full diff page comparing two manifests.

func (*ManifestDiffHandler) ServeHTTP

func (h *ManifestDiffHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ManifestHealthHandler

type ManifestHealthHandler struct {
	BaseUIHandler
}

ManifestHealthHandler handles HTMX polling for manifest health status

func (*ManifestHealthHandler) ServeHTTP

type NotFoundHandler

type NotFoundHandler struct {
	BaseUIHandler
}

NotFoundHandler handles 404 errors

func (*NotFoundHandler) ServeHTTP

func (h *NotFoundHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type PageData

type PageData struct {
	User             *db.User // Logged-in user (nil if not logged in)
	Query            string   // Search query from URL parameter
	RegistryURL      string   // Docker registry domain (e.g., "buoy.cr")
	SiteURL          string   // Website domain (e.g., "seamark.dev")
	ClientName       string   // Brand name for templates (e.g., "AT Container Registry")
	ClientShortName  string   // Brand name for templates (e.g., "ATCR")
	OciClient        string   // Preferred OCI client for pull commands (e.g., "docker", "podman")
	AIAdvisorEnabled bool     // True when AI Image Advisor is available
	SourceURL        string   // Source code URL for the footer "Source" link
	CurrentPath      string   // Request path (used for OAuth return_to)
}

PageData contains common fields shared across all page templates

func NewPageData

func NewPageData(r *http.Request, h *BaseUIHandler) PageData

NewPageData creates a PageData struct with common fields populated from the request

type PageMeta

type PageMeta struct {
	Title       string // Page title (required; empty falls back to SiteName in template)
	Description string // Meta description (required; empty omits the tag entirely)
	Canonical   string // Canonical URL (optional)
	Robots      string // Robots directive, e.g. "noindex" (optional, defaults to "index, follow")
	OGType      string // OpenGraph type, defaults to "website"
	OGImage     string // OpenGraph image URL (optional)
	OGImageAlt  string // OpenGraph image alt text — improves social-share a11y
	OGLocale    string // OpenGraph locale (e.g. "en_US"); blank falls back in template
	TwitterCard string // Twitter card type, defaults to "summary_large_image"
	SiteName    string // Site name for og:site_name (falls back to "ATCR" in template)
	JSONLD      []any  // JSON-LD structured data objects (optional)
}

PageMeta holds all metadata for a page's <head> section. Use the builder methods to construct it with a fluent API.

func NewPageMeta

func NewPageMeta(title, description string) *PageMeta

NewPageMeta creates a new PageMeta with required fields and sensible defaults. Callers should not pass empty title/description — the template falls back to the SiteName for missing title and omits missing description, but those are last-resort defenses.

func (*PageMeta) WithCanonical

func (m *PageMeta) WithCanonical(url string) *PageMeta

WithCanonical sets the canonical URL.

func (*PageMeta) WithJSONLD

func (m *PageMeta) WithJSONLD(data ...any) *PageMeta

WithJSONLD sets the JSON-LD structured data objects.

func (*PageMeta) WithOGImage

func (m *PageMeta) WithOGImage(url string) *PageMeta

WithOGImage sets the OpenGraph image URL.

func (*PageMeta) WithOGImageAlt added in v0.1.3

func (m *PageMeta) WithOGImageAlt(alt string) *PageMeta

WithOGImageAlt sets the alt text for the OpenGraph image. Strongly recommended when OGImage is set — screen readers on social platforms read this out.

func (*PageMeta) WithOGLocale added in v0.1.3

func (m *PageMeta) WithOGLocale(locale string) *PageMeta

WithOGLocale overrides the default "en_US" locale.

func (*PageMeta) WithOGType

func (m *PageMeta) WithOGType(ogType string) *PageMeta

WithOGType sets the OpenGraph type (e.g., "website", "profile", "article").

func (*PageMeta) WithRobots

func (m *PageMeta) WithRobots(robots string) *PageMeta

WithRobots sets the robots meta directive (e.g., "noindex").

func (*PageMeta) WithSiteName

func (m *PageMeta) WithSiteName(name string) *PageMeta

WithSiteName sets the site name for og:site_name. Pass the caller's ClientShortName — forgetting this on a branded deployment (e.g. Seamark) leaks "ATCR" into social previews.

type PreviewMarkdownHandler

type PreviewMarkdownHandler struct {
	BaseUIHandler
}

PreviewMarkdownHandler renders markdown to HTML for the editor preview tab

func (*PreviewMarkdownHandler) ServeHTTP

type PrivacyPolicyHandler

type PrivacyPolicyHandler struct {
	BaseUIHandler
}

PrivacyPolicyHandler handles the /privacy page

func (*PrivacyPolicyHandler) ServeHTTP

func (h *PrivacyPolicyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type QuotaStats

type QuotaStats struct {
	UserDID     string `json:"userDid"`
	UniqueBlobs int    `json:"uniqueBlobs"`
	TotalSize   int64  `json:"totalSize"`
	Limit       *int64 `json:"limit,omitempty"` // nil = unlimited
	Tier        string `json:"tier,omitempty"`  // e.g., "deckhand", "bosun", "owner"
}

QuotaStats mirrors the hold service response

type RepoOGHandler

type RepoOGHandler struct {
	BaseUIHandler
}

RepoOGHandler generates OpenGraph images for repository pages

func (*RepoOGHandler) ServeHTTP

func (h *RepoOGHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RepositoryPageHandler

type RepositoryPageHandler struct {
	BaseUIHandler
}

RepositoryPageHandler handles the public repository page

func (*RepositoryPageHandler) ServeHTTP

type RepositoryTagsHandler

type RepositoryTagsHandler struct {
	BaseUIHandler
}

RepositoryTagsHandler returns the tags+manifests HTMX partial for a repository

func (*RepositoryTagsHandler) ServeHTTP

type ResolvedHold

type ResolvedHold struct {
	DID string
	URL string
}

ResolvedHold contains the resolved DID and URL for a hold endpoint, after following any successor chain.

func ResolveHold

func ResolveHold(ctx context.Context, database *sql.DB, holdEndpoint string) (*ResolvedHold, error)

ResolveHold resolves a hold endpoint (DID, URL, or hostname) to its final DID and URL, following a single successor hop if one exists in the captain records.

type RevokeDeviceHandler

type RevokeDeviceHandler struct {
	BaseUIHandler
}

RevokeDeviceHandler handles DELETE /api/devices/{id}

func (*RevokeDeviceHandler) ServeHTTP

func (h *RevokeDeviceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SaveRepoPageHandler

type SaveRepoPageHandler struct {
	BaseUIHandler
}

SaveRepoPageHandler saves user-edited description to the PDS repo page record

func (*SaveRepoPageHandler) ServeHTTP

func (h *SaveRepoPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SbomDetailsHandler

type SbomDetailsHandler struct {
	BaseUIHandler
}

SbomDetailsHandler handles requests for the SBOM detail content. Returns an HTML fragment (sbom-details partial) for insertion into the digest page.

func (*SbomDetailsHandler) ServeHTTP

func (h *SbomDetailsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ScanDownloadHandler added in v0.1.3

type ScanDownloadHandler struct {
	BaseUIHandler
}

ScanDownloadHandler serves raw scan blobs (SPDX JSON or Grype JSON) as file downloads. GET /api/scan-download?digest=sha256:...&holdEndpoint=did:web:...&type=vuln|sbom

func (*ScanDownloadHandler) ServeHTTP added in v0.1.3

func (h *ScanDownloadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ScanResultHandler

type ScanResultHandler struct {
	BaseUIHandler
}

ScanResultHandler handles HTMX requests for vulnerability scan badges. Returns an HTML fragment (vuln-badge partial) that replaces the placeholder span.

func (*ScanResultHandler) ServeHTTP

func (h *ScanResultHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SearchHandler

type SearchHandler struct {
	BaseUIHandler
}

SearchHandler handles the search page. When a query is provided, it runs the search server-side so the page works without JavaScript; htmx only takes over for the "Load More" pagination link.

func (*SearchHandler) ServeHTTP

func (h *SearchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SearchResultsHandler

type SearchResultsHandler struct {
	BaseUIHandler
}

SearchResultsHandler serves the search-results partial for htmx Load More pagination. Returns just the grid fragment, not a full page.

func (*SearchResultsHandler) ServeHTTP

func (h *SearchResultsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SelectedTagData

type SelectedTagData struct {
	Info            *db.TagWithPlatforms
	LayerCount      int
	CompressedSize  int64 // largest platform's size for multi-arch; size for single-arch
	ScanBatchParams []template.HTML
}

SelectedTagData holds all data for the currently selected tag on the repo page.

type SettingsHandler

type SettingsHandler struct {
	BaseUIHandler
}

SettingsHandler handles the settings page — dispatches per-tab.

func (*SettingsHandler) ServeHTTP

func (h *SettingsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP redirects /settings to /settings/user.

func (*SettingsHandler) ServeTab added in v0.1.3

func (h *SettingsHandler) ServeTab(tab string) http.HandlerFunc

ServeTab returns an http.Handler for a specific settings tab. If HX-Request is set, only the panel fragment is rendered.

type SignupContinueHandler added in v0.1.3

type SignupContinueHandler struct {
	BaseUIHandler
}

SignupContinueHandler serves /signup/continue — the branded handoff.

GET renders the interstitial. POST kicks off OAuth with prompt=create and redirects to the provider's authorize URL.

func (*SignupContinueHandler) ServeHTTP added in v0.1.3

type SignupHandler added in v0.1.3

type SignupHandler struct {
	BaseUIHandler
}

SignupHandler serves GET /signup — the provider picker.

func (*SignupHandler) ServeHTTP added in v0.1.3

func (h *SignupHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SignupProvider added in v0.1.3

type SignupProvider struct {
	// Domain is the brand hostname shown to the user on the picker and
	// interstitial — typically the site they already know (tangled.org).
	Domain string

	// AuthServerDomain is the actual PDS origin the OAuth redirect points
	// at. When blank it defaults to Domain. Set this only when the brand
	// the user recognizes is not the same host as the PDS (e.g. the
	// tangled.org site runs against a tngl.sh PDS).
	AuthServerDomain string

	// AvatarPath is the provider's mark. For mono vector marks, AvatarMono
	// should be true and this should point to a monochrome SVG used as a
	// CSS mask (the fill value in the file is irrelevant — theme color is
	// applied via `background-color` on the element). For raster avatars
	// (photographs, brand-colored icons that should render unchanged),
	// AvatarMono is false and this is emitted as a plain `<img>`.
	AvatarPath string

	// AvatarMono toggles the mask-based theme-aware render pipeline. True
	// for single-color SVG marks that should invert with theme; false for
	// raster or multi-color art that should render as-is.
	AvatarMono bool

	// RegionFlag is the flag emoji shown before the region code.
	RegionFlag string

	// Region is a short code shown in the region chip ("US", "EU", ...).
	Region string

	// RegionFullName is the long form shown in the chip's title attribute
	// for hover/assistive tech ("United States", "European Union").
	RegionFullName string

	// TermsURL and PrivacyURL link out to the provider's policies (new tab).
	// Blank links are omitted rather than rendered as dead links.
	TermsURL   string
	PrivacyURL string
}

SignupProvider is a curated Atmosphere PDS that accepts prompt=create.

v1 keeps the list hardcoded. When the community has a curated directory of providers we can link or syndicate, this moves to a config file.

func (SignupProvider) AuthServerHost added in v0.1.3

func (p SignupProvider) AuthServerHost() string

AuthServerHost returns the origin string (https://domain) passed to the OAuth resolver. Prefers AuthServerDomain when set (so the brand label on the row can differ from the PDS — e.g. tangled.org displayed, tngl.sh used for auth). Hardcoded scheme is intentional — PAR against http PDSes violates the AT Protocol OAuth spec.

type StarRepositoryHandler

type StarRepositoryHandler struct {
	BaseUIHandler
}

StarRepositoryHandler handles starring a repository

func (*StarRepositoryHandler) ServeHTTP

type StarredRepositoriesHandler added in v0.1.3

type StarredRepositoriesHandler struct {
	BaseUIHandler
}

StarredRepositoriesHandler renders /u/{handle}/starred — the list of repos the viewed user has starred. Stars whose target repo no longer exists or is inaccessible are silently dropped by the underlying query.

func (*StarredRepositoriesHandler) ServeHTTP added in v0.1.3

type StorageHandler

type StorageHandler struct {
	BaseUIHandler
}

StorageHandler handles the storage quota API endpoint Returns an HTML partial for HTMX to swap into the settings page

func (*StorageHandler) ServeHTTP

func (h *StorageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SubscriptionCheckoutHandler

type SubscriptionCheckoutHandler struct {
	BaseUIHandler
}

SubscriptionCheckoutHandler redirects to Stripe checkout.

func (*SubscriptionCheckoutHandler) ServeHTTP

type SubscriptionDisplay

type SubscriptionDisplay struct {
	UserDID         string
	CurrentTier     string
	PaymentsEnabled bool
	Tiers           []TierDisplay
	SubscriptionID  string
	BillingInterval string
	HideBilling     bool
}

SubscriptionDisplay is the template-friendly subscription data.

type SubscriptionPortalHandler

type SubscriptionPortalHandler struct {
	BaseUIHandler
}

SubscriptionPortalHandler redirects to Stripe billing portal.

func (*SubscriptionPortalHandler) ServeHTTP

type TermsOfServiceHandler

type TermsOfServiceHandler struct {
	BaseUIHandler
}

TermsOfServiceHandler handles the /terms page

func (*TermsOfServiceHandler) ServeHTTP

type TestWebhookHandler

type TestWebhookHandler struct {
	BaseUIHandler
}

TestWebhookHandler sends a test payload

func (*TestWebhookHandler) ServeHTTP

func (h *TestWebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type TierDisplay

type TierDisplay struct {
	ID                string
	Name              string
	Description       string
	Features          []string
	PriceCentsMonthly int
	PriceCentsYearly  int
	PriceMonthly      string // e.g. "$5/mo"
	PriceYearly       string // e.g. "$50/yr"
	IsCurrent         bool
}

TierDisplay is a template-friendly tier.

type UnstarRepositoryHandler

type UnstarRepositoryHandler struct {
	BaseUIHandler
}

UnstarRepositoryHandler handles unstarring a repository

func (*UnstarRepositoryHandler) ServeHTTP

type UpdateAIAdvisorHandler

type UpdateAIAdvisorHandler struct {
	BaseUIHandler
}

UpdateAIAdvisorHandler handles toggling the AI Image Advisor setting

func (*UpdateAIAdvisorHandler) ServeHTTP

type UpdateAutoRemoveUntaggedHandler

type UpdateAutoRemoveUntaggedHandler struct {
	BaseUIHandler
}

UpdateAutoRemoveUntaggedHandler handles toggling the auto-remove-untagged setting

func (*UpdateAutoRemoveUntaggedHandler) ServeHTTP

type UpdateDefaultHoldHandler

type UpdateDefaultHoldHandler struct {
	BaseUIHandler
}

UpdateDefaultHoldHandler handles updating the default hold

func (*UpdateDefaultHoldHandler) ServeHTTP

type UpdateOciClientHandler

type UpdateOciClientHandler struct {
	BaseUIHandler
}

UpdateOciClientHandler handles updating the preferred OCI client

func (*UpdateOciClientHandler) ServeHTTP

type UpgradeBannerHandler

type UpgradeBannerHandler struct {
	BaseUIHandler
}

UpgradeBannerHandler returns an HTMX fragment with an upgrade nudge when the user is viewing an older tagged manifest.

func (*UpgradeBannerHandler) ServeHTTP

func (h *UpgradeBannerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type UploadAvatarHandler

type UploadAvatarHandler struct {
	BaseUIHandler
}

UploadAvatarHandler handles uploading/updating a repository avatar

func (*UploadAvatarHandler) ServeHTTP

func (h *UploadAvatarHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type UserOGHandler

type UserOGHandler struct {
	BaseUIHandler
}

UserOGHandler generates OpenGraph images for user profile pages

func (*UserOGHandler) ServeHTTP

func (h *UserOGHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type UserPageHandler

type UserPageHandler struct {
	BaseUIHandler
}

UserPageHandler handles the public user page showing all images for a user

func (*UserPageHandler) ServeHTTP

func (h *UserPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type VulnDetailsHandler

type VulnDetailsHandler struct {
	BaseUIHandler
}

VulnDetailsHandler handles requests for the vulnerability detail modal content. Returns an HTML fragment (vuln-details partial) for insertion into the modal body.

func (*VulnDetailsHandler) ServeHTTP

func (h *VulnDetailsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type VulnDiffEntry

type VulnDiffEntry struct {
	Status string // "fixed", "new", "unchanged"
	Vuln   vulnMatch
}

VulnDiffEntry represents a vulnerability categorized by diff status.

type WebhooksHandler

type WebhooksHandler struct {
	BaseUIHandler
}

WebhooksHandler returns the webhooks list partial via HTMX

func (*WebhooksHandler) ServeHTTP

func (h *WebhooksHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址