(w http.ResponseWriter, r *http.Request)
| 276 | } |
| 277 | |
| 278 | func (h *handler) updateUser(w http.ResponseWriter, r *http.Request) { |
| 279 | var u UserReq |
| 280 | if err := json.NewDecoder(r.Body).Decode(&u); err != nil { |
| 281 | http.Error(w, "error decoding request body", http.StatusBadRequest) |
| 282 | return |
| 283 | } |
| 284 | |
| 285 | claims := r.Context().Value(authKey{}).(*token.UserClaims) |
| 286 | u.Email = claims.Email |
| 287 | |
| 288 | updated, err := h.client.UpdateUser(h.ctx, toPBUserReq(u)) |
| 289 | if err != nil { |
| 290 | http.Error(w, "error updating user", http.StatusInternalServerError) |
| 291 | return |
| 292 | } |
| 293 | |
| 294 | res := toUserRes(updated) |
| 295 | w.Header().Set("Content-Type", "application/json") |
| 296 | w.WriteHeader(http.StatusOK) |
| 297 | json.NewEncoder(w).Encode(res) |
| 298 | } |
| 299 | |
| 300 | func (h handler) deleteUser(w http.ResponseWriter, r *http.Request) { |
| 301 | id := chi.URLParam(r, "id") |
nothing calls this directly
no test coverage detected