| 260 | } |
| 261 | |
| 262 | func (h *handler) listUsers(w http.ResponseWriter, r *http.Request) { |
| 263 | users, err := h.client.ListUsers(h.ctx, &pb.UserReq{}) |
| 264 | if err != nil { |
| 265 | http.Error(w, "error listing users", http.StatusInternalServerError) |
| 266 | return |
| 267 | } |
| 268 | |
| 269 | var res ListUserRes |
| 270 | for _, u := range users.GetUsers() { |
| 271 | res.Users = append(res.Users, toUserRes(u)) |
| 272 | } |
| 273 | |
| 274 | w.Header().Set("Content-Type", "application/json") |
| 275 | json.NewEncoder(w).Encode(res) |
| 276 | } |
| 277 | |
| 278 | func (h *handler) updateUser(w http.ResponseWriter, r *http.Request) { |
| 279 | var u UserReq |