package handler import ( "net/http" "github.com/gin-gonic/gin" ) type ChangeUserRoleRequest struct { Role string `json:"role"` } func (h *Handler) changeUserRole(c *gin.Context) { var input ChangeUserRoleRequest if err := c.BindJSON(&input); err != nil { newErrorResponse(c, http.StatusBadRequest, err.Error()) return } username := c.Param("username") if username == "" { newErrorResponse(c, http.StatusBadRequest, "Ошибка в строке запроса") return } role, err := h.services.ChangeUserRole(username, input.Role) if err != nil { newErrorResponse(c, http.StatusBadRequest, err.Error()) return } c.JSON(http.StatusOK, map[string]interface{}{ "newRole": role, }) }