1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-10-31 16:00:05 -04:00

Make accounts PUT and POST return the resulting Account object

This commit is contained in:
Aaron Lindsay 2016-09-29 09:17:57 -04:00
parent aedad87d07
commit 449b4ee760

View File

@ -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 {