MCPcopy Create free account
hub / github.com/devinterface/startersaas-go-api / Update

Method Update

endpoints/team.endpoint.go:95–122  ·  view source on GitHub ↗

Update function

(ctx *fiber.Ctx)

Source from the content-addressed store, hash-verified

93
94// Update function
95func (teamEndpoint *TeamEndpoint) Update(ctx *fiber.Ctx) error {
96 me, _ := teamEndpoint.CurrentUser(ctx)
97 if can := teamEndpoint.Can(ctx, models.AdminRole); !can {
98 return ctx.Status(401).JSON(fiber.Map{
99 "message": "You are not authorized to perform this action",
100 })
101 }
102
103 var inputMap = make(map[string]interface{})
104 ctx.BodyParser(&inputMap)
105
106 v := validate.Map(inputMap)
107 v.StringRule("name", "string")
108
109 if !v.Validate() {
110 return ctx.Status(422).JSON(v.Errors)
111 }
112
113 updateTeam, err := teamService.Update(ctx.Params("id"), me.AccountID, v.SafeData())
114 if err != nil {
115 return ctx.Status(404).JSON(fiber.Map{
116 "message": err.Error(),
117 })
118 }
119
120 showTeam := models.ShowTeamSerializer().Transform(updateTeam)
121 return ctx.JSON(showTeam)
122}
123
124// Delete function
125func (teamEndpoint *TeamEndpoint) Delete(ctx *fiber.Ctx) error {

Callers

nothing calls this directly

Calls 3

ShowTeamSerializerFunction · 0.92
CurrentUserMethod · 0.80
CanMethod · 0.80

Tested by

no test coverage detected