a73x

internal/server/web/embed.go

Ref:   Size: 658 B   History

package web

import (
	"embed"
	"io/fs"
	"net/http"
)

// dist holds the built SvelteKit app. `make web` populates internal/server/web/dist
// from the SvelteKit static build; only .gitkeep is committed, so a fresh checkout
// embeds an empty tree and the handler serves a "UI not built" notice until built.
// The all: prefix includes SvelteKit's _app directory (leading underscore).
//
//go:embed all:dist
var dist embed.FS

// Handler serves the embedded SPA with index.html fallback.
func Handler() http.Handler {
	sub, err := fs.Sub(dist, "dist")
	if err != nil {
		panic(err) // dist is always embedded (at least .gitkeep)
	}
	return spaHandler(sub)
}