1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-12-26 07:33:21 -05:00

Make users PUT AND POST return the resulting User

This commit is contained in:
Aaron Lindsay 2016-10-04 08:01:28 -04:00
parent 4f2f15783a
commit d5b1260b27

View File

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