diff options
| author | Leonardo Bishop <me@leonardobishop.net> | 2026-01-16 18:45:03 +0000 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.net> | 2026-01-16 18:45:03 +0000 |
| commit | eddd55bc5dcfe36d8a56645d4b7e2e49429a933c (patch) | |
| tree | 3eaf75f72225004980e99bc4a848a0cf5f942090 /web/handler/index.go | |
| parent | e6cbb8415490524034561102b6c9f03e92e4dae7 (diff) | |
Cache /userinfo for a bit
Diffstat (limited to 'web/handler/index.go')
| -rw-r--r-- | web/handler/index.go | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/web/handler/index.go b/web/handler/index.go index 9279151..8b3d43c 100644 --- a/web/handler/index.go +++ b/web/handler/index.go @@ -2,7 +2,7 @@ package handler import ( "html/template" - "log" + "log/slog" "net/http" "git.leonardobishop.net/instancer/pkg/registry" @@ -13,14 +13,20 @@ func GetIndex(tmpl *template.Template, registryClient *registry.RegistryClient) 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) + slog.Error("could not list repositories", "cause", err) + tmpl.ExecuteTemplate(w, "problem.html", struct { + Error string + ShowLogout bool + }{ + Error: "Error occured fetching available challenges. Please try again.", + ShowLogout: false, + }) return } session := r.Context().Value("session").(*session.UserSession) - if err := tmpl.ExecuteTemplate(w, "index.html", struct { + tmpl.ExecuteTemplate(w, "index.html", struct { Challenges []string Name string Team string @@ -28,9 +34,6 @@ func GetIndex(tmpl *template.Template, registryClient *registry.RegistryClient) Challenges: challenges, Name: session.Name, Team: session.TeamName, - }); err != nil { - http.Error(w, "Internal server error", http.StatusInternalServerError) - return - } + }) } } |
