AppServer
Table of contents
Application server control functions
Related global functions
func FinishApp()
Finishes application
func OpenBrowser(url string) bool
Open browser with specific URL locally. Useful for applications which run on local machine or for debug purposes
func StartApp(addr string, createContentFunc func(Session) SessionContent, params AppParams)
Create a new application, start it and runs its main loop
Example
main.go
func main() {
rui.AddEmbedResources(&resources)
//addr := rui.GetLocalIP() + ":8080"
addr := "localhost:8080"
rui.OpenBrowser("http://" + addr)
rui.StartApp(addr, createDemo, rui.AppParams{
Title: "RUI demo",
Icon: "icon.svg",
TitleColor: rui.Color(0xffc0ded9),
})
}
type demoSession struct {
rootView rui.View
}
func (demo *demoSession) CreateRootView(session rui.Session) rui.View {
demo.rootView = rui.CreateViewFromResources(session, "mainView")
if demo.rootView == nil {
return nil
}
return demo.rootView
}
resources.go
//go:build !wasm
package main
import "embed"
//go:embed resources media
var resources embed.FS