Documentation
¶
Overview ¶
Package fe mounts the Githome web front: the human-facing, server-rendered HTML surface that sits beside the REST and GraphQL APIs in the same binary. It owns no domain logic. It resolves data through the domain services, builds view models with fe/view, and renders them with fe/render; its middleware live in fe/webmw and its URL rules in fe/route. The front never calls the public API over HTTP: it shares the process and the domain layer directly. See implementation/00 and implementation/02.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Mount ¶
Mount registers the web front's dynamic routes on root and returns the servable handler: the asset tree peeled off in front of root. It does not touch the global middleware or the error handler the API surface installed: it registers its routes through scoped subrouters, so the web middleware chain applies to web routes only and the API keeps its own. The page chain carries recovery, the session, the color mode, the CSRF guard and the flash reader; the asset chain carries only recovery, so a static file does not pay for a session lookup.
The returned handler, not root, is what the server must serve when the web front is enabled. The static asset tree cannot share root's net/http mux: it is served under a greedy /assets/{file...} pattern, and that overlaps the front's own /{owner}/{repo}/... wildcards (an owner could be named "assets") in a way the Go 1.22 mux refuses to register. So assets live on their own router and are dispatched ahead of root by path prefix. See implementation/02.
Types ¶
type AuthPwStore ¶ added in v0.1.3
type AuthPwStore interface {
PasswordHashFor(ctx context.Context, login string) (pk int64, hash string, err error)
InsertUserWithPassword(ctx context.Context, login, email, hash string) (int64, error)
UserLoginExists(ctx context.Context, login string) (bool, error)
}
AuthPwStore is the narrow password-auth interface the auth handlers need. The concrete *store.Store satisfies it; cmd/githome passes the store directly since it already imports store. fe/mount never imports store directly (doc 01 §6).
type Deps ¶
type Deps struct {
Render *render.Set
View *view.Builder
Auth AuthPwStore
OAuthSvc webauth.OAuthService
Tokens websettings.TokenService
Repos *domain.RepoService
Hooks *domain.HookService
Checks *domain.ChecksService
Issues *domain.IssueService
Pulls *domain.PRService
Reviews *domain.ReviewService
Search *domain.SearchService
Users *domain.UserService
Events *domain.EventService
Social *domain.SocialService
Notifications *domain.NotificationService
URLs *presenter.URLBuilder
Markup *markup.Renderer
Sessions *webmw.Sessions
CSRF *webmw.CSRF
Flash *webmw.Flash
Logger *slog.Logger
HomeHandler mizu.Handler // optional: overrides the default landing page
}
Deps are the web front's dependencies. F0 needs the render set, the view builder, and the three stateful middleware (session, CSRF, flash) plus a logger. F1 adds the domain repo service and the presenter URL builder its code-browsing handlers read; a zero service leaves its routes unmounted, mirroring how the REST surface mounts. F2 adds the shared markup renderer the README and Markdown blob views render through; a nil renderer falls back to the escaped-source view, so the front still serves with markup unconfigured. Auth (added F1) is the password store the sign-in/join routes need; nil leaves those routes unmounted. HomeHandler overrides the default landing page; browse mode uses it to redirect straight to the repository root.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package assets owns the Githome web front's built static assets: the content-hashed CSS and JS bundles, the manifest that maps a logical name to its hashed file, and the Octicon icon registry the render layer inlines.
|
Package assets owns the Githome web front's built static assets: the content-hashed CSS and JS bundles, the manifest that maps a logical name to its hashed file, and the Octicon icon registry the render layer inlines. |
|
build
command
Command build regenerates the embedded web-front bundle in fe/assets/dist.
|
Command build regenerates the embedded web-front bundle in fe/assets/dist. |
|
Package render is the Githome web front's html/template engine.
|
Package render is the Githome web front's html/template engine. |
|
Package route holds the Githome web front's URL-space rules: the reserved top-level names that a user or organization login may not take, and the ref-versus-path split that the tree and blob URLs need.
|
Package route holds the Githome web front's URL-space rules: the reserved top-level names that a user or organization login may not take, and the ref-versus-path split that the tree and blob URLs need. |
|
Package view builds the view models the render layer turns into HTML.
|
Package view builds the view models the render layer turns into HTML. |
|
web
|
|
|
auth
Package auth holds the Githome web front's authentication handlers: sign-in, sign-up, and sign-out.
|
Package auth holds the Githome web front's authentication handlers: sign-in, sign-up, and sign-out. |
|
checks
Package checks holds the Githome web front's commit-checks surface: the page at /{owner}/{repo}/checks/{ref} that shows the status-check rollup for a ref, its check-run rows, and its commit-status rows.
|
Package checks holds the Githome web front's commit-checks surface: the page at /{owner}/{repo}/checks/{ref} that shows the status-check rollup for a ref, its check-run rows, and its commit-status rows. |
|
compare
Package compare holds the Githome web front's branch-comparison handlers: the branch picker that starts a comparison, and the range view that shows the three-dot diff between two branches with an optional pull-request creation form.
|
Package compare holds the Githome web front's branch-comparison handlers: the branch picker that starts a comparison, and the range view that shows the three-dot diff between two branches with an optional pull-request creation form. |
|
dashboard
Package dashboard holds the global, viewer-scoped lists at the reserved top-level /issues and /pulls names: the cross-repo "your issues" and "your pull requests" pages (spec doc 02 section 1.1, doc 09 section 1.6).
|
Package dashboard holds the global, viewer-scoped lists at the reserved top-level /issues and /pulls names: the cross-repo "your issues" and "your pull requests" pages (spec doc 02 section 1.1, doc 09 section 1.6). |
|
home
Package home holds the Githome web front's landing surface: the root page at / and its named twin at /dashboard.
|
Package home holds the Githome web front's landing surface: the root page at / and its named twin at /dashboard. |
|
issues
Package issues holds the Githome web front's issues handlers: the index with its search-and-filter bar, the detail page with its comment timeline and sidebar, the comment composer, the reactions, and the new-issue form.
|
Package issues holds the Githome web front's issues handlers: the index with its search-and-filter bar, the detail page with its comment timeline and sidebar, the comment composer, the reactions, and the new-issue form. |
|
notifications
Package notifications holds the viewer-scoped notifications inbox at the reserved top-level /notifications name (spec doc 02 section 1.1).
|
Package notifications holds the viewer-scoped notifications inbox at the reserved top-level /notifications name (spec doc 02 section 1.1). |
|
profile
Package profile holds the Githome web front's profile handlers: the user and organization overview at /{owner} and its repositories tab.
|
Package profile holds the Githome web front's profile handlers: the user and organization overview at /{owner} and its repositories tab. |
|
pulls
Package pulls holds the Githome web front's pull-request handlers: the index with its state tabs, the PR shell the four tabs hang off, the Conversation timeline, the Commits tab, the read-only Files-changed diff, and the merge box with its poll fragment and merge mutation.
|
Package pulls holds the Githome web front's pull-request handlers: the index with its state tabs, the PR shell the four tabs hang off, the Conversation timeline, the Commits tab, the read-only Files-changed diff, and the merge box with its poll fragment and merge mutation. |
|
repo
Package repo holds the Githome web front's code-browsing handlers: the repo home, the tree and blob views, the raw byte view, commit history, the branch and tag overviews, and the file finder.
|
Package repo holds the Githome web front's code-browsing handlers: the repo home, the tree and blob views, the raw byte view, commit history, the branch and tag overviews, and the file finder. |
|
reposettings
Package reposettings holds the Githome web front's repository settings handlers.
|
Package reposettings holds the Githome web front's repository settings handlers. |
|
search
Package search holds the Githome web front's search surface: the global /search page and the in-repo /{owner}/{repo}/search page.
|
Package search holds the Githome web front's search surface: the global /search page and the in-repo /{owner}/{repo}/search page. |
|
settings
Package settings holds the Githome web front's account settings handlers.
|
Package settings holds the Githome web front's account settings handlers. |
|
Package webmw holds the Githome web front's middleware: the signed session cookie that resolves the viewer, the color-mode cookie, the CSRF guard, the one-shot flash cookie, and the panic recovery that renders the HTML error page.
|
Package webmw holds the Githome web front's middleware: the signed session cookie that resolves the viewer, the color-mode cookie, the CSRF guard, the one-shot flash cookie, and the panic recovery that renders the HTML error page. |