MCPcopy
hub / github.com/harness/harness / HandleCreate

Function HandleCreate

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

HandleCreate returns an http.HandlerFunc that processes an http.Request to create the named user account in the system.

(userCtrl *user.Controller)

Source from the content-addressed store, hash-verified

26// HandleCreate returns an http.HandlerFunc that processes an http.Request
27// to create the named user account in the system.
28func HandleCreate(userCtrl *user.Controller) http.HandlerFunc {
29 return func(w http.ResponseWriter, r *http.Request) {
30 ctx := r.Context()
31 session, _ := request.AuthSessionFrom(ctx)
32
33 in := new(user.CreateInput)
34 err := json.NewDecoder(r.Body).Decode(in)
35 if err != nil {
36 render.BadRequestf(ctx, w, "Invalid request body: %s.", err)
37 return
38 }
39
40 usr, err := userCtrl.Create(ctx, session, in)
41 if err != nil {
42 render.TranslatedUserError(ctx, w, err)
43 return
44 }
45
46 render.JSON(w, http.StatusCreated, usr)
47 }
48}

Callers 1

setupAdminFunction · 0.92

Calls 6

AuthSessionFromFunction · 0.92
BadRequestfFunction · 0.92
TranslatedUserErrorFunction · 0.92
JSONFunction · 0.92
DecodeMethod · 0.65
CreateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…