summaryrefslogtreecommitdiffstats
path: root/web/handler/index.go
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.net>2026-01-07 23:39:53 +0000
committerLeonardo Bishop <me@leonardobishop.net>2026-01-07 23:39:53 +0000
commit03cd6bdfbd473dba3f3dc50a1b15e389aac5bc70 (patch)
tree5fea2b1840e298aaab953add749fb9226bd4a710 /web/handler/index.go
Initial commit
Diffstat (limited to 'web/handler/index.go')
-rw-r--r--web/handler/index.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/web/handler/index.go b/web/handler/index.go
new file mode 100644
index 0000000..5cf44cf
--- /dev/null
+++ b/web/handler/index.go
@@ -0,0 +1,34 @@
+package handler
+
+import (
+ "html/template"
+ "log"
+ "net/http"
+
+ "git.leonardobishop.net/instancer/pkg/registry"
+ "git.leonardobishop.net/instancer/pkg/session"
+)
+
+func GetIndex(tmpl *template.Template, registryClient *registry.RegistryClient) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ challenges, err := registryClient.ListRepositories()
+ if err != nil {
+ log.Printf("Could not list repositories: %v", err)
+ http.Error(w, "Internal server error", http.StatusInternalServerError)
+ return
+ }
+
+ session := r.Context().Value("session").(*session.UserSession)
+
+ if err := tmpl.ExecuteTemplate(w, "index.html", struct {
+ Challenges []string
+ Team string
+ }{
+ Challenges: challenges,
+ Team: session.Team,
+ }); err != nil {
+ http.Error(w, "Internal server error", http.StatusInternalServerError)
+ return
+ }
+ }
+}