aboutsummaryrefslogtreecommitdiff
path: root/internal/webui
diff options
context:
space:
mode:
authorJulien Dessaux2021-04-06 16:46:05 +0200
committerJulien Dessaux2021-04-06 16:46:05 +0200
commit92c5e1e4d073c82e12e26170379cb5c8d90ab2e8 (patch)
treed862f6ea5a3f22c6c8ad268c7ddf5bb2536fa95c /internal/webui
parentAdded a flag to specify a configuration file and wrote a proper readme (diff)
downloadtrains-92c5e1e4d073c82e12e26170379cb5c8d90ab2e8.tar.gz
trains-92c5e1e4d073c82e12e26170379cb5c8d90ab2e8.tar.bz2
trains-92c5e1e4d073c82e12e26170379cb5c8d90ab2e8.zip
Added trainStop config parameter which was wrongly hardcoded
Diffstat (limited to 'internal/webui')
-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)