From c4d226db2286ccb121cc245660ed032f7a745c63 Mon Sep 17 00:00:00 2001 From: Roberto Hidalgo Date: Wed, 4 Jan 2023 00:30:32 -0600 Subject: [PATCH] actually test api before deploying --- internal/server/admin.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/internal/server/admin.go b/internal/server/admin.go index c4fc17f..544884e 100644 --- a/internal/server/admin.go +++ b/internal/server/admin.go @@ -90,32 +90,33 @@ func createUser(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { } func getUser(w http.ResponseWriter, r *http.Request, params httprouter.Params) { - var user *user.User + this := user.User{} idString := params.ByName("id") - if err := _db.Get(user, db.Cond{"handle": idString}); err != nil { + if err := _db.Get(&this, db.Cond{"handle": idString}); err != nil { sendError(w, err) return } - writeJSON(w, user) + writeJSON(w, this) } func updateUser(w http.ResponseWriter, r *http.Request, params httprouter.Params) { logrus.Infof("updating user: %s", params.ByName("id")) - var user *user.User - if err := _db.Get(user, db.Cond{"handle": params.ByName("id")}); err != nil { + user := user.User{} + if err := _db.Get(&user, db.Cond{"handle": params.ByName("id")}); err != nil { + logrus.Error(err) http.NotFound(w, r) return } - user, err := userFromRequest(r, user) + modified, err := userFromRequest(r, &user) if err != nil { sendError(w, err) return } - if err := _db.Collection("user").UpdateReturning(user); err != nil { + if err := _db.Collection("user").UpdateReturning(modified); err != nil { sendError(w, err) return }