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)
| 65 | // @Failure 500 {object} responses.InternalServerError |
| 66 | // @Router /webhooks [get] |
| 67 | func (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 |
nothing calls this directly
no test coverage detected