docs: route handler docs

This commit is contained in:
Marc 2024-09-13 00:13:49 -04:00
parent 8427ae6aaa
commit 8dafeb7e17
Signed by: marc
GPG key ID: 048E042F22B5DC79

14
main.go
View file

@ -17,15 +17,25 @@ type Link struct {
Title string `json:"title"` 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) { func healthcheck(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200) w.WriteHeader(200)
} }
// About page
//
// Static content for the about page.
func about(w http.ResponseWriter, r *http.Request) { func about(w http.ResponseWriter, r *http.Request) {
tmpl, _ := template.New("about.html.tmpl").ParseFiles("templates/about.html.tmpl") tmpl, _ := template.New("about.html.tmpl").ParseFiles("templates/about.html.tmpl")
tmpl.Execute(w, nil) tmpl.Execute(w, nil)
} }
// Feeds list
//
// Lists all feed elements in store.
func listContent(w http.ResponseWriter, r *http.Request) { func listContent(w http.ResponseWriter, r *http.Request) {
links := []Link{} links := []Link{}
for _, feed := range SharedCache.List("feeds") { for _, feed := range SharedCache.List("feeds") {
@ -38,6 +48,10 @@ func listContent(w http.ResponseWriter, r *http.Request) {
tmpl.Execute(w, links) 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) { func manageContent(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" { if r.Method == "POST" {
r.ParseForm() r.ParseForm()