search

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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 New

func New(d Deps) *Handlers

New wires the handler set from its dependencies.

func (*Handlers) Global

func (h *Handlers) Global(c *mizu.Ctx) error

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

func (h *Handlers) Resolve(next mizu.Handler) mizu.Handler

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.

func (*Handlers) Scoped

func (h *Handlers) Scoped(c *mizu.Ctx) error

Scoped renders /{owner}/{repo}/search. The repo was resolved and read-gated by Resolve, so a private repo a viewer cannot read is already a 404 before this runs. It injects the repo: scope and drops the cross-repository types, with code as the default.

Jump to

Keyboard shortcuts

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