From 449b4ee760eadd9fcf8c49dfe7ff19de1908a552 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Thu, 29 Sep 2016 09:17:57 -0400 Subject: [PATCH] Make accounts PUT and POST return the resulting Account object --- accounts.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/accounts.go b/accounts.go index faa1db4..edea7e7 100644 --- a/accounts.go +++ b/accounts.go @@ -362,7 +362,13 @@ func AccountHandler(w http.ResponseWriter, r *http.Request) { return } - WriteSuccess(w) + w.WriteHeader(201 /*Created*/) + err = account.Write(w) + if err != nil { + WriteError(w, 999 /*Internal Error*/) + log.Print(err) + return + } } else if r.Method == "GET" { var accountid int64 n, err := GetURLPieces(r.URL.Path, "/account/%d", &accountid) @@ -438,7 +444,12 @@ func AccountHandler(w http.ResponseWriter, r *http.Request) { return } - WriteSuccess(w) + err = account.Write(w) + if err != nil { + WriteError(w, 999 /*Internal Error*/) + log.Print(err) + return + } } else if r.Method == "DELETE" { accountid, err := GetURLID(r.URL.Path) if err != nil {