Returns the parameterized user requested. All validation is completed in the middleware for this route. @Summary Get user by name @ID get-user-by-name @Security CoderSessionToken @Produce json @Tags Users @Param user path string true "User ID, username, or me" @Success 200 {object} codersdk.User @R
(rw http.ResponseWriter, r *http.Request)
| 758 | // @Success 200 {object} codersdk.User |
| 759 | // @Router /api/v2/users/{user} [get] |
| 760 | func (api *API) userByName(rw http.ResponseWriter, r *http.Request) { |
| 761 | ctx := r.Context() |
| 762 | user := httpmw.UserParam(r) |
| 763 | organizationIDs, err := userOrganizationIDs(ctx, api, user) |
| 764 | if err != nil { |
| 765 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 766 | Message: "Internal error fetching user's organizations.", |
| 767 | Detail: err.Error(), |
| 768 | }) |
| 769 | return |
| 770 | } |
| 771 | |
| 772 | sdkUser := db2sdk.User(user, organizationIDs) |
| 773 | api.enrichUserAISeat(ctx, &sdkUser) |
| 774 | httpapi.Write(ctx, rw, http.StatusOK, sdkUser) |
| 775 | } |
| 776 | |
| 777 | // Returns recent build parameters for the signed-in user. |
| 778 | // |
nothing calls this directly
no test coverage detected