Documentation
¶
Overview ¶
Package web embeds the built frontend via embed.FS, keeping the control plane a single static binary with no Node runtime required on the server, and serves it with client-side-routing fallback, so a hard refresh or direct link to a TanStack Router path like /apps/foo resolves correctly instead of 404ing at the server before React Router ever gets a chance to handle it.
Index ¶
Constants ¶
const DashboardCSP = "default-src 'self'; " +
"script-src 'self'; " +
"style-src 'self' 'unsafe-inline'; " +
"img-src 'self' data: https:; " +
"font-src 'self' data:; " +
"connect-src 'self'; " +
"object-src 'none'; " +
"base-uri 'self'; " +
"form-action 'self'; " +
"frame-ancestors 'none'"
DashboardCSP mirrors internal/api's contentSecurityPolicy; img-src also allows https: because bundled docs pages embed remote badge images.
Variables ¶
var DistFS embed.FS
DistFS is intentionally empty (Go's embed.FS zero value, no //go:embed directive) in the default build. web/dist is a gitignored build artifact that doesn't exist until `npm run build` runs; a bare //go:embed dist here would make plain `go build ./...` fail on any checkout that hasn't built the frontend yet, breaking it repo-wide, including every quick sanity `go build`/`go vet`/`golangci-lint run` both this project's git hooks and CI already rely on. The real frontend is embedded only by an explicit `-tags embedweb` build, after `cd web && npm run build`; see embed_real.go and Handler's doc comment for what happens when it isn't.
Functions ¶
func Handler ¶
Handler serves the embedded frontend. If this binary wasn't built with -tags embedweb (the default, see embed_stub.go), it serves a 501 with an actionable message instead of panicking or 404ing silently: a missing frontend is a build configuration fact worth surfacing clearly, not a routing failure to debug.
func HandlerFromFS ¶
HandlerFromFS is HandlerWithHead over a caller-supplied filesystem holding a "dist" directory, so a test can serve a fixture shell without embedweb.
func HandlerWithHead ¶
func HandlerWithHead(b *brand.Brand, head HeadOptions) http.Handler
HandlerWithHead is Handler plus share-tag overrides for the shell; a zero HeadOptions behaves exactly like Handler.
Types ¶
type HeadOptions ¶
type HeadOptions struct {
Title string
Description string
URL string
ImageURL string
ImageAlt string
ImageWidth int
ImageHeight int
// CSP replaces DashboardCSP on every response when set (demo analytics).
CSP string
}
HeadOptions overrides the shell's share tags. The zero value changes nothing, so normal instances render exactly as before.