From d5b1260b278c5f41e5483796304393f12259e28c Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Tue, 4 Oct 2016 08:01:28 -0400 Subject: [PATCH] Make users PUT AND POST return the resulting User --- users.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/users.go b/users.go index d12c085..3629c3c 100644 --- a/users.go +++ b/users.go @@ -131,7 +131,13 @@ func UserHandler(w http.ResponseWriter, r *http.Request) { return } - WriteSuccess(w) + w.WriteHeader(201 /*Created*/) + err = user.Write(w) + if err != nil { + WriteError(w, 999 /*Internal Error*/) + log.Print(err) + return + } } else { user, err := GetUserFromSession(r) if err != nil { @@ -188,7 +194,12 @@ func UserHandler(w http.ResponseWriter, r *http.Request) { return } - WriteSuccess(w) + err = user.Write(w) + if err != nil { + WriteError(w, 999 /*Internal Error*/) + log.Print(err) + return + } } else if r.Method == "DELETE" { count, err := DB.Delete(&user) if count != 1 || err != nil {