about summary refs log tree commit diff stats
path: root/svc/query.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/query.go
parent7db28dd705dd5463b5e2e9cf6f5fc87db25533ad (diff)
downloadgetwtxt-e53b843a93922f21289b9fc4958f1dfc47a49bdf.tar.gz
some functions were missing comments. added those in where needed.
Diffstat (limited to 'svc/query.go')
-rw-r--r--svc/query.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/svc/query.go b/svc/query.go
index 24541fc..7047df3 100644
--- a/svc/query.go
+++ b/svc/query.go
@@ -32,6 +32,8 @@ import (
 	"github.com/gorilla/mux"
 )
 
+// Wrapper to check if an error is non-nil, then
+// log the error if applicable.
 func apiErrCheck(err error, r *http.Request) {
 	if err != nil {
 		uip := getIPFromCtx(r.Context())
@@ -39,6 +41,7 @@ func apiErrCheck(err error, r *http.Request) {
 	}
 }
 
+// Deduplicates a slice of strings
 func dedupe(list []string) []string {
 	out := []string{}
 	seen := make(map[string]bool)
@@ -134,6 +137,8 @@ func apiEndpointQuery(w http.ResponseWriter, r *http.Request) error {
 	return err
 }
 
+// For composite queries, join the various slices of strings
+// into a single slice of strings, then deduplicates them.
 func joinQueryOuts(data ...[]string) []string {
 	single := []string{}
 	for _, e := range data {
@@ -142,6 +147,7 @@ func joinQueryOuts(data ...[]string) []string {
 	return dedupe(single)
 }
 
+// Performs a composite query against the statuses.
 func compositeStatusQuery(query string, r *http.Request) []string {
 	var wg sync.WaitGroup
 	var out, out2, out3 []string