From 8dafeb7e17024a85d286803f7570dee6496bb912 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Fri, 13 Sep 2024 00:13:49 -0400 Subject: [PATCH] docs: route handler docs --- main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.go b/main.go index f239d4f..29e7747 100644 --- a/main.go +++ b/main.go @@ -17,15 +17,25 @@ type Link struct { Title string `json:"title"` } +// Healthcheck route +// +// Confirms that the app is alive without guarantees +// about it being fully-functional. func healthcheck(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) } +// About page +// +// Static content for the about page. func about(w http.ResponseWriter, r *http.Request) { tmpl, _ := template.New("about.html.tmpl").ParseFiles("templates/about.html.tmpl") tmpl.Execute(w, nil) } +// Feeds list +// +// Lists all feed elements in store. func listContent(w http.ResponseWriter, r *http.Request) { links := []Link{} for _, feed := range SharedCache.List("feeds") { @@ -38,6 +48,10 @@ func listContent(w http.ResponseWriter, r *http.Request) { tmpl.Execute(w, links) } +// Manage content +// +// Interface to add new feed subscriptions and get a list +// of current subs. func manageContent(w http.ResponseWriter, r *http.Request) { if r.Method == "POST" { r.ParseForm()