From d3d9df2268345cb3bdcdcfa5712dfde0fdf7dbca Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Sat, 11 May 2019 04:07:34 -0400 Subject: commenting early --- handlers.go | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/handlers.go b/handlers.go index ac52559..3998228 100644 --- a/handlers.go +++ b/handlers.go @@ -10,6 +10,17 @@ import ( "github.com/gorilla/mux" ) +// handles "/" +func indexHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", htmlutf8) + n, err := w.Write([]byte(getwtxt)) + if err != nil || n == 0 { + log.Printf("Error writing to HTTP stream: %v\n", err) + } + +} + +// handles "/api" func apiBaseHandler(w http.ResponseWriter, r *http.Request) { timerfc3339, err := time.Now().MarshalText() if err != nil { @@ -26,14 +37,8 @@ func apiBaseHandler(w http.ResponseWriter, r *http.Request) { } } -func indexHandler(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", htmlutf8) - n, err := w.Write([]byte(getwtxt)) - if err != nil || n == 0 { - log.Printf("Error writing to HTTP stream: %v\n", err) - } - -} +// handles "/api/plain" +// maybe add json/xml support later func apiFormatHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) format := vars["format"] @@ -44,6 +49,8 @@ func apiFormatHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Error writing to HTTP stream: %v\n", err) } } + +// handles "/api/plain/(users|mentions|tweets)" func apiEndpointHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) format := vars["format"] @@ -56,6 +63,8 @@ func apiEndpointHandler(w http.ResponseWriter, r *http.Request) { } } + +// handles "/api/plain/tags" func apiTagsBaseHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) format := vars["format"] @@ -67,6 +76,8 @@ func apiTagsBaseHandler(w http.ResponseWriter, r *http.Request) { } } + +// handles "/api/plain/tags/[a-zA-Z0-9]+" func apiTagsHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) format := vars["format"] -- cgit 1.4.1-2-gfad0