diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-05-21 18:49:43 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-05-21 18:59:56 -0400 |
commit | 4f0847bb24a5df77f88c883461491a2f6fd955d7 (patch) | |
tree | 0f9e2eef1f6bfa4f3a09370730ad8351c1ce24dd /post.go | |
parent | 61e81ea7acfc01e8b7ea33156a36c15b0674c79f (diff) | |
download | getwtxt-4f0847bb24a5df77f88c883461491a2f6fd955d7.tar.gz |
runtime bugs related to api output
Diffstat (limited to 'post.go')
-rw-r--r-- | post.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/post.go b/post.go index e829538..95cc6d3 100644 --- a/post.go +++ b/post.go @@ -20,6 +20,7 @@ func apiPostUser(w http.ResponseWriter, r *http.Request) { 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")) return } @@ -28,6 +29,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) return } @@ -39,6 +41,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) return } @@ -46,8 +49,9 @@ func apiPostUser(w http.ResponseWriter, r *http.Request) { return } - statuses, err := registry.ParseUserTwtxt(out) + 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) return } |