aboutsummaryrefslogtreecommitdiff
path: root/internal/webui/app.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--internal/webui/app.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/webui/app.go b/internal/webui/app.go
index f510074..f6082dc 100644
--- a/internal/webui/app.go
+++ b/internal/webui/app.go
@@ -14,6 +14,9 @@ import (
// the api client object
var client *navitia_api_client.Client
+// the webui configuration
+var conf *config.Config
+
//go:embed html/*
var templatesFS embed.FS
@@ -35,7 +38,7 @@ type Departure struct {
func rootHandler(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
var p Page
- if d, err := client.GetDepartures(); err != nil {
+ if d, err := client.GetDepartures(conf.TrainStop); err != nil {
log.Printf("%+v\n%s\n", d, err)
} else {
for i := 0; i < len(d.Departures); i++ {
@@ -64,6 +67,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p Page) {
}
func Run(c *config.Config) {
+ conf = c
client = navitia_api_client.NewClient(c.Token)
http.Handle("/static/", http.FileServer(http.FS(staticFS)))
http.HandleFunc("/", rootHandler)