Documentation
¶
Index ¶
- func CheckPortAvailable(port int) bool
- func EnsureFrontendDevServer(ctx context.Context, routePrefix string) (int, chan struct{}, error)
- func FindAvailablePort(startPort int, maxAttempts int) (int, error)
- func FormatTemplateHtml(opts FormatOptions) (string, error)
- func Init(fs embed.FS, tmpl string)
- func JoinRoutePrefix(routePrefix string, requestPath string) string
- func NormalizeRoutePrefix(prefix string) string
- func ProxyDev(mux *http.ServeMux, vitePort int, routePrefix string) error
- func RegisterAPI(mux *http.ServeMux) error
- func Serve(port int, dev bool, routePrefix string) error
- func ServeComponent(port int, opts ServeOptions) error
- func SetDataDir(dataDir string)
- func Static(mux *http.ServeMux, opts StaticOptions) error
- type FormatOptions
- type ServeOptions
- type StaticOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPortAvailable ¶
func EnsureFrontendDevServer ¶
EnsureFrontendDevServer starts `bun run dev` for the React app on an auto-selected free port (starting at 5173) and blocks until the port is reachable. It returns the chosen port along with a channel that closes once the sub-process has fully terminated after ctx is cancelled.
Selecting a free port dynamically means multiple projects can run in --dev mode in parallel; it also avoids accidentally proxying to another project's vite instance that happens to own 5173.
func FindAvailablePort ¶
FindAvailablePort finds a port starting from startPort
func FormatTemplateHtml ¶
func FormatTemplateHtml(opts FormatOptions) (string, error)
FormatTemplateHtml formats the template HTML with the given options
func JoinRoutePrefix ¶
func NormalizeRoutePrefix ¶
NormalizeRoutePrefix converts values like "my-app" and "/my-app/" to "/my-app". Empty and "/" mean the app is mounted at the host root.
func RegisterAPI ¶
func ServeComponent ¶
func ServeComponent(port int, opts ServeOptions) error
func SetDataDir ¶
func SetDataDir(dataDir string)
Types ¶
type FormatOptions ¶
type FormatOptions struct {
Title string // __TITLE__ placeholder
Render string // __RENDER__ placeholder (default: "renderComponent")
Component string // __COMPONENT__ placeholder (mandatory)
ComponentProps string // __COMPONENT_PROPS__ placeholder (default: "{}")
}
FormatOptions contains the options for formatting the template HTML