MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / loadUserRecord

Function loadUserRecord

internal/web/api_v1_users.go:25–35  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
25func 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}
38func apiV1GetUser(w http.ResponseWriter, r *http.Request) {

Callers 6

apiV1GetUserPermissionsFunction · 0.85
apiV1PutUserPermissionsFunction · 0.85
apiV1GetUserFunction · 0.85
apiV1PatchUserFunction · 0.85
apiV1GetCharacterFunction · 0.85
apiV1GetUserYAMLFunction · 0.85

Calls 3

GetByUserIdFunction · 0.92
LoadUserByIdFunction · 0.92
writeAPIErrorFunction · 0.85

Tested by

no test coverage detected