Files
wotra/ui.go
T
aksdb 58479668b6 ✨ Run PocketBase as the wotra binary
The root package is now the entry point: one binary that serves the
PocketBase API, applies the migrations and ships the SvelteKit build
from web/build as a single-page app. The legacy chi entry point is
gone.

Note that the image is embedded unconditionally, so a Go build needs
at least the tracked web/build/.gitkeep and a web build has to run
first to get a working UI.
2026-11-29 17:06:46 +00:00

28 lines
553 B
Go

package main
import (
"embed"
"io/fs"
"mime"
"github.com/pocketbase/pocketbase/apis"
"github.com/pocketbase/pocketbase/core"
)
//go:embed all:web/build
var webBuild embed.FS
func registerUI(app core.App) {
_ = mime.AddExtensionType(".webmanifest", "application/manifest+json")
sub, err := fs.Sub(webBuild, "web/build")
if err != nil {
panic(err)
}
app.OnServe().BindFunc(func(se *core.ServeEvent) error {
if !se.Router.HasRoute("GET", "/{path...}") {
se.Router.GET("/{path...}", apis.Static(sub, true))
}
return se.Next()
})
}