aboutsummaryrefslogtreecommitdiff
path: root/internal/webui/webui.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-04-21 17:23:07 +0200
committerJulien Dessaux2021-04-21 17:23:07 +0200
commit4a2fb7e82d5d617298cb28b66485fc6f30c55781 (patch)
tree4ae55d8208e3ebf603f3a17ac56f6efd0e011efc /internal/webui/webui.go
parentImplemented the ResumeSession function (diff)
downloadtrains-4a2fb7e82d5d617298cb28b66485fc6f30c55781.tar.gz
trains-4a2fb7e82d5d617298cb28b66485fc6f30c55781.tar.bz2
trains-4a2fb7e82d5d617298cb28b66485fc6f30c55781.zip
Reworked the webui package, added authentication feature and tests
Diffstat (limited to '')
-rw-r--r--internal/webui/webui.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/webui/webui.go b/internal/webui/webui.go
new file mode 100644
index 0000000..6ce5bb4
--- /dev/null
+++ b/internal/webui/webui.go
@@ -0,0 +1,25 @@
+package webui
+
+import (
+ "log"
+ "net/http"
+
+ "git.adyxax.org/adyxax/trains/pkg/config"
+ "git.adyxax.org/adyxax/trains/pkg/database"
+ "git.adyxax.org/adyxax/trains/pkg/navitia_api_client"
+)
+
+func Run(c *config.Config, dbEnv *database.DBEnv) {
+ e := env{
+ conf: c,
+ dbEnv: dbEnv,
+ navitia: navitia_api_client.NewClient(c.Token),
+ }
+ http.Handle("/", handler{&e, rootHandler})
+ http.Handle("/login", handler{&e, loginHandler})
+ http.Handle("/static/", http.FileServer(http.FS(staticFS)))
+
+ listenStr := c.Address + ":" + c.Port
+ log.Printf("Starting webui on %s", listenStr)
+ log.Fatal(http.ListenAndServe(listenStr, nil))
+}