MCPcopy
hub / github.com/harness/harness / HandleUpdate

Function HandleUpdate

app/api/handler/users/update.go:28–52  ·  view source on GitHub ↗

HandleUpdate returns a http.HandlerFunc that processes an http.Request to update a user account.

(userCtrl *user.Controller)

Source from the content-addressed store, hash-verified

26// HandleUpdate returns a http.HandlerFunc that processes an http.Request
27// to update a user account.
28func HandleUpdate(userCtrl *user.Controller) http.HandlerFunc {
29 return func(w http.ResponseWriter, r *http.Request) {
30 ctx := r.Context()
31 session, _ := request.AuthSessionFrom(ctx)
32 userUID, err := request.GetUserUIDFromPath(r)
33 if err != nil {
34 render.TranslatedUserError(ctx, w, err)
35 return
36 }
37
38 in := new(user.UpdateInput)
39 if err = json.NewDecoder(r.Body).Decode(in); err != nil {
40 render.BadRequestf(ctx, w, "Invalid request body: %s.", err)
41 return
42 }
43
44 usr, err := userCtrl.Update(ctx, session, userUID, in)
45 if err != nil {
46 render.TranslatedUserError(ctx, w, err)
47 return
48 }
49
50 render.JSON(w, http.StatusOK, usr)
51 }
52}

Callers 1

setupAdminFunction · 0.92

Calls 7

AuthSessionFromFunction · 0.92
GetUserUIDFromPathFunction · 0.92
TranslatedUserErrorFunction · 0.92
BadRequestfFunction · 0.92
JSONFunction · 0.92
DecodeMethod · 0.65
UpdateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…