MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / Update

Method Update

api/pkg/handlers/webhook_handler.go:198–224  ·  view source on GitHub ↗

Update an entities.Webhook @Summary Update a webhook @Description Update a webhook for the currently authenticated user @Security ApiKeyAuth @Tags Webhooks @Accept json @Produce json @Param webhookID path string true "ID of the webhook" default(32343a19-da5

(c fiber.Ctx)

Source from the content-addressed store, hash-verified

196// @Failure 500 {object} responses.InternalServerError
197// @Router /webhooks/{webhookID} [put]
198func (h *WebhookHandler) Update(c fiber.Ctx) error {
199 ctx, span, ctxLogger := h.tracer.StartFromFiberCtxWithLogger(c, h.logger)
200 defer span.End()
201
202 var request requests.WebhookUpdate
203 if err := c.Bind().Body(&request); err != nil {
204 msg := fmt.Sprintf("cannot marshall params [%s] into [%T]", c.Body(), request)
205 ctxLogger.Warn(stacktrace.Propagate(err, msg))
206 return h.responseBadRequest(c, err)
207 }
208
209 request.WebhookID = c.Params("webhookID")
210 if errors := h.validator.ValidateUpdate(ctx, h.userIDFomContext(c), request.Sanitize()); len(errors) != 0 {
211 msg := fmt.Sprintf("validation errors [%s], while updating user [%+#v]", spew.Sdump(errors), request)
212 ctxLogger.Warn(stacktrace.NewError(msg))
213 return h.responseUnprocessableEntity(c, errors, "validation errors while updating webhook")
214 }
215
216 user, err := h.service.Update(ctx, request.ToUpdateParams(h.userFromContext(c)))
217 if err != nil {
218 msg := fmt.Sprintf("cannot update user with params [%+#v]", request)
219 ctxLogger.Error(stacktrace.Propagate(err, msg))
220 return h.responseInternalServerError(c)
221 }
222
223 return h.responseOK(c, "webhook updated successfully", user)
224}

Callers

nothing calls this directly

Calls 13

SanitizeMethod · 0.95
ToUpdateParamsMethod · 0.95
responseBadRequestMethod · 0.80
userIDFomContextMethod · 0.80
userFromContextMethod · 0.80
responseOKMethod · 0.80
WarnMethod · 0.65
UpdateMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected