Documentation
¶
Overview ¶
Package search holds the Githome web front's search surface: the global /search page and the in-repo /{owner}/{repo}/search page. It parses the ?q= query with the same parser the REST search uses, calls the one domain search service the API also calls (so the page and the API never disagree about what matches or what a viewer may see), maps the hits into fe/view result models with every URL precomputed through fe/route, and renders one template. The result types the domain does not serve (users, commits) are absent from the type rail rather than shown disabled, so the UI never advertises a capability it does not have. A repository the viewer cannot read was turned into a hard 404 by the scoped Resolve middleware before any handler ran (the 404-not-403 rule), and every control is a plain link or GET form that works with no JavaScript. See implementation/12 section 2.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
Search *domain.SearchService
Repos *domain.RepoService
URLs *presenter.URLBuilder
Render *render.Set
View *view.Builder
Logger *slog.Logger
}
Deps are the search handlers' dependencies: the domain search service for every query, the repo service the scoped page resolves and read-gates the repository through, the presenter for avatar URLs, the render set, the view builder for the shell chrome, and a logger for the incomplete-walk notice.
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers is the search handler set. One is built at boot and shared; it holds no per-request state.
func (*Handlers) Global ¶
Global renders /search, the host-wide search. An empty q renders the landing (no rows, no count) rather than an empty result set; otherwise it runs the active type and renders the results page.
func (*Handlers) Resolve ¶
Resolve loads the repository named by the {owner} and {repo} path parameters for the in-repo search, read-gated for the viewer, and stores it on the context. A missing repository, or a private one the viewer cannot see, renders the same 404, so a private repo never leaks through the status code. This mirrors the issues and code-browsing Resolve so the surfaces gate identically.