loadUserRecord loads a UserRecord by id, checking the online cache first. Writes a 404 error response and returns nil when the user does not exist.
(w http.ResponseWriter, userId int)
| 23 | // loadUserRecord loads a UserRecord by id, checking the online cache first. |
| 24 | // Writes a 404 error response and returns nil when the user does not exist. |
| 25 | func loadUserRecord(w http.ResponseWriter, userId int) *users.UserRecord { |
| 26 | if u := users.GetByUserId(userId); u != nil { |
| 27 | return u |
| 28 | } |
| 29 | u, err := users.LoadUserById(userId) |
| 30 | if err != nil { |
| 31 | writeAPIError(w, http.StatusNotFound, "user not found") |
| 32 | return nil |
| 33 | } |
| 34 | return u |
| 35 | } |
| 36 | |
| 37 | // GET /admin/api/v1/users/{userid} |
| 38 | func apiV1GetUser(w http.ResponseWriter, r *http.Request) { |
no test coverage detected