diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-12-19 21:21:56 -0500 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-12-19 21:21:56 -0500 |
commit | e53b843a93922f21289b9fc4958f1dfc47a49bdf (patch) | |
tree | a98cc9358ccf773a7615b42802bb825d7be0bc0d /svc/handlers.go | |
parent | 7db28dd705dd5463b5e2e9cf6f5fc87db25533ad (diff) | |
download | getwtxt-e53b843a93922f21289b9fc4958f1dfc47a49bdf.tar.gz |
some functions were missing comments. added those in where needed.
Diffstat (limited to 'svc/handlers.go')
-rw-r--r-- | svc/handlers.go | 7 |
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 { |