summary refs log tree commit diff stats
path: root/svc/handlers.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-12-19 21:21:56 -0500
committerBen Morrison <ben@gbmor.dev>2019-12-19 21:21:56 -0500
commite53b843a93922f21289b9fc4958f1dfc47a49bdf (patch)
treea98cc9358ccf773a7615b42802bb825d7be0bc0d /svc/handlers.go
parent7db28dd705dd5463b5e2e9cf6f5fc87db25533ad (diff)
downloadgetwtxt-e53b843a93922f21289b9fc4958f1dfc47a49bdf.tar.gz
some functions were missing comments. added those in where needed.
Diffstat (limited to 'svc/handlers.go')
-rw-r--r--svc/handlers.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/svc/handlers.go b/svc/handlers.go
index cd0d920..ee58622 100644
--- a/svc/handlers.go
+++ b/svc/handlers.go
@@ -31,6 +31,8 @@ import (
 	"github.com/gorilla/mux"
 )
 
+// Takes the modtime of one of the static files, derives
+// an FNV hash from it, then truncates it.
 func getEtagFromTime(modtime time.Time) string {
 	shabytes, err := modtime.MarshalText()
 	errLog("", err)
@@ -38,11 +40,15 @@ func getEtagFromTime(modtime time.Time) string {
 	return fmt.Sprintf("%x", bytes[:16])
 }
 
+// Takes the body of a response to a request, derives an
+// FNV hash from it, then truncates it. Used for non-static
+// responses.
 func getEtag(data []byte) string {
 	bytes := fnv.New32().Sum(data)
 	return fmt.Sprintf("%x", bytes[:16])
 }
 
+// Serves index.html and the stylesheet to go with it.
 func servStatic(w http.ResponseWriter, isCSS bool) error {
 	pingAssets()
 	staticCache.mu.RLock()
@@ -89,6 +95,7 @@ func apiFormatHandler(w http.ResponseWriter, r *http.Request) {
 	staticHandler(w, r)
 }
 
+// Serves all tweets without pagination.
 func apiAllTweetsHandler(w http.ResponseWriter, r *http.Request) {
 	out, err := twtxtCache.QueryAllStatuses()
 	if err != nil {