diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-05-21 22:04:19 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-05-21 22:04:19 -0400 |
commit | bded77fe18a8acb6397835a836ac68f7435bf3d4 (patch) | |
tree | 77e319f53b1d7cb79dc2e5f5a48f44556429ece6 /post.go | |
parent | 4f0847bb24a5df77f88c883461491a2f6fd955d7 (diff) | |
download | getwtxt-bded77fe18a8acb6397835a836ac68f7435bf3d4.tar.gz |
runtime bugs re: http400 and database reading on startup
Diffstat (limited to 'post.go')
-rw-r--r-- | post.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/post.go b/post.go index 95cc6d3..b9c830e 100644 --- a/post.go +++ b/post.go @@ -14,14 +14,15 @@ 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) + _, _ = w.Write([]byte(fmt.Sprintf("400 Bad Request: %v\n", err))) + log400(r, err) return } nick := r.FormValue("nickname") urls := r.FormValue("url") if nick == "" || urls == "" { _, _ = w.Write([]byte("400 Bad Request: Nickname or URL Missing\n")) - log400(w, r, fmt.Errorf("nickname or URL missing")) + log400(r, fmt.Errorf("nickname or URL missing")) return } @@ -30,7 +31,7 @@ func apiPostUser(w http.ResponseWriter, r *http.Request) { out, remoteRegistry, err := registry.GetTwtxt(urls) if err != nil { _, _ = w.Write([]byte(fmt.Sprintf("400 Bad Request: %v\n", err))) - log400(w, r, err) + log400(r, err) return } @@ -42,7 +43,7 @@ func apiPostUser(w http.ResponseWriter, r *http.Request) { err := twtxtCache.ScrapeRemoteRegistry(urls) if err != nil { _, _ = w.Write([]byte(fmt.Sprintf("400 Bad Request: %v\n", err))) - log400(w, r, err) + log400(r, err) return } log200(r) @@ -52,15 +53,17 @@ func apiPostUser(w http.ResponseWriter, r *http.Request) { statuses, err := registry.ParseUserTwtxt(out, nick, urls) if err != nil { _, _ = w.Write([]byte(fmt.Sprintf("400 Bad Request: %v\n", err))) - log400(w, r, err) + log400(r, err) return } err = twtxtCache.AddUser(nick, urls, uip, statuses) if err != nil { - log400(w, r, err) + _, _ = w.Write([]byte(fmt.Sprintf("400 Bad Request: %v\n", err))) + log400(r, err) return } log200(r) + _, _ = w.Write([]byte(fmt.Sprintf("200 OK\n"))) } |