diff --git a/example/webui/index.html b/example/webui/index.html index 30d1179..c1be3ca 100644 --- a/example/webui/index.html +++ b/example/webui/index.html @@ -28,12 +28,12 @@
-

Talk to Smart Agent

+

Talk to '{{.Character.Name}}'

- +

Clients:

@@ -41,6 +41,7 @@
+

Status:

@@ -55,7 +56,7 @@
-

Agent is currently:

+

Agent:

diff --git a/example/webui/main.go b/example/webui/main.go index 33c25dd..f8d905f 100644 --- a/example/webui/main.go +++ b/example/webui/main.go @@ -115,7 +115,7 @@ func main() { mux := http.NewServeMux() - mux.Handle("GET /", http.HandlerFunc(app.Home)) + mux.Handle("GET /", http.HandlerFunc(app.Home(agent))) // External notifications (e.g. webhook) mux.Handle("POST /notify", http.HandlerFunc(app.Notify)) @@ -131,14 +131,21 @@ func main() { log.Fatal(err) } -func (a *App) Home(w http.ResponseWriter, r *http.Request) { - tmpl, err := template.ParseFiles("index.html") - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } +func (a *App) Home(agent *Agent) func(w http.ResponseWriter, r *http.Request) { + return func(w http.ResponseWriter, r *http.Request) { + tmpl, err := template.ParseFiles("index.html") + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } - tmpl.Execute(w, nil) + tmpl.Execute(w, + struct { + Character Character + }{ + Character: agent.Character, + }) + } } func (a *App) SSE(w http.ResponseWriter, r *http.Request) {