summaryrefslogtreecommitdiff
path: root/pkg/webui/index.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/webui/index.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/pkg/webui/index.go b/pkg/webui/index.go
new file mode 100644
index 0000000..1168098
--- /dev/null
+++ b/pkg/webui/index.go
@@ -0,0 +1,31 @@
+package webui
+
+import (
+ "fmt"
+ "net/http"
+
+ "git.adyxax.org/adyxax/tfstated/pkg/model"
+)
+
+type Page struct {
+ LightMode bool
+ Precedent string
+ Section string
+ Title string
+}
+
+func makePage(r *http.Request, page *Page) *Page {
+ settings := r.Context().Value(model.SettingsContextKey{}).(*model.Settings)
+ page.LightMode = settings.LightMode
+ return page
+}
+
+func handleIndexGET() http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path == "/" {
+ http.Redirect(w, r, "/states", http.StatusFound)
+ } else {
+ errorResponse(w, http.StatusNotFound, fmt.Errorf("Page not found"))
+ }
+ })
+}