summary refs log tree commit diff stats
path: root/post.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-21 23:44:03 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-22 00:26:16 -0400
commit37be25ffddafdf5b7ed4c86b25e3e1ad3a6b3362 (patch)
tree63dcbc8d46e1c5089fc339bc2ad07745a9d4e51b /post.go
parent54a4f6f720979dc8c8d6224acd24f04d147ef761 (diff)
downloadgetwtxt-37be25ffddafdf5b7ed4c86b25e3e1ad3a6b3362.tar.gz
tuning query handling
Diffstat (limited to 'post.go')
-rw-r--r--post.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/post.go b/post.go
index 25d1902..4078cf6 100644
--- a/post.go
+++ b/post.go
@@ -14,13 +14,14 @@ import (
 // registry before adding each user to the local cache.
 func apiPostUser(w http.ResponseWriter, r *http.Request) {
 	if err := r.ParseForm(); err != nil {
-		log400(w, r, err)
+		log400(w, r, err.Error())
 		return
 	}
+
 	nick := r.FormValue("nickname")
 	urls := r.FormValue("url")
 	if nick == "" || urls == "" {
-		log400(w, r, fmt.Errorf("Nickname or URL missing"))
+		log400(w, r, "Nickname or URL missing")
 		return
 	}
 
@@ -28,7 +29,7 @@ func apiPostUser(w http.ResponseWriter, r *http.Request) {
 
 	out, remoteRegistry, err := registry.GetTwtxt(urls)
 	if err != nil {
-		log400(w, r, err)
+		log400(w, r, err.Error())
 		return
 	}
 
@@ -37,9 +38,8 @@ func apiPostUser(w http.ResponseWriter, r *http.Request) {
 		remoteRegistries.List = append(remoteRegistries.List, urls)
 		remoteRegistries.Mu.Unlock()
 
-		err := twtxtCache.ScrapeRemoteRegistry(urls)
-		if err != nil {
-			log400(w, r, err)
+		if err := twtxtCache.ScrapeRemoteRegistry(urls); err != nil {
+			log400(w, r, err.Error())
 			return
 		}
 		log200(r)
@@ -48,13 +48,12 @@ func apiPostUser(w http.ResponseWriter, r *http.Request) {
 
 	statuses, err := registry.ParseUserTwtxt(out, nick, urls)
 	if err != nil {
-		log400(w, r, err)
+		log400(w, r, err.Error())
 		return
 	}
 
-	err = twtxtCache.AddUser(nick, urls, uip, statuses)
-	if err != nil {
-		log400(w, r, err)
+	if err := twtxtCache.AddUser(nick, urls, uip, statuses); err != nil {
+		log400(w, r, err.Error())
 		return
 	}