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

Method Index

api/pkg/handlers/webhook_handler.go:67–92  ·  view source on GitHub ↗

Index returns the webhooks of a user @Summary Get webhooks of a user @Description Get the webhooks of a user @Security ApiKeyAuth @Tags Webhooks @Accept json @Produce json @Param skip query int false "number of webhooks to skip" minimum(0) @Param query q

(c fiber.Ctx)

Source from the content-addressed store, hash-verified

65// @Failure 500 {object} responses.InternalServerError
66// @Router /webhooks [get]
67func (h *WebhookHandler) Index(c fiber.Ctx) error {
68 ctx, span, ctxLogger := h.tracer.StartFromFiberCtxWithLogger(c, h.logger)
69 defer span.End()
70
71 var request requests.WebhookIndex
72 if err := c.Bind().Query(&request); err != nil {
73 msg := fmt.Sprintf("cannot marshall URL [%s] into %T", c.OriginalURL(), request)
74 ctxLogger.Warn(stacktrace.Propagate(err, msg))
75 return h.responseBadRequest(c, err)
76 }
77
78 if errors := h.validator.ValidateIndex(ctx, request.Sanitize()); len(errors) != 0 {
79 msg := fmt.Sprintf("validation errors [%s], while fetching webhooks [%+#v]", spew.Sdump(errors), request)
80 ctxLogger.Warn(stacktrace.NewError(msg))
81 return h.responseUnprocessableEntity(c, errors, "validation errors while fetching webhooks")
82 }
83
84 webhooks, err := h.service.Index(ctx, h.userIDFomContext(c), request.ToIndexParams())
85 if err != nil {
86 msg := fmt.Sprintf("cannot get webhooks with params [%+#v]", request)
87 ctxLogger.Error(stacktrace.Propagate(err, msg))
88 return h.responseInternalServerError(c)
89 }
90
91 return h.responseOK(c, fmt.Sprintf("fetched %d %s", len(webhooks), h.pluralize("webhook", len(webhooks))), webhooks)
92}
93
94// Delete a webhook
95// @Summary Delete webhook

Callers

nothing calls this directly

Calls 13

SanitizeMethod · 0.95
ToIndexParamsMethod · 0.95
responseBadRequestMethod · 0.80
userIDFomContextMethod · 0.80
responseOKMethod · 0.80
pluralizeMethod · 0.80
WarnMethod · 0.65
IndexMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected