Index returns the discord integrations of a user @Summary Get discord integrations of a user @Description Get the discord integrations of a user @Security ApiKeyAuth @Tags DiscordIntegration @Accept json @Produce json @Param skip query int false "number of discor
(c fiber.Ctx)
| 83 | // @Failure 500 {object} responses.InternalServerError |
| 84 | // @Router /discord-integrations [get] |
| 85 | func (h *DiscordHandler) Index(c fiber.Ctx) error { |
| 86 | ctx, span, ctxLogger := h.tracer.StartFromFiberCtxWithLogger(c, h.logger) |
| 87 | defer span.End() |
| 88 | |
| 89 | var request requests.DiscordIndex |
| 90 | if err := c.Bind().Query(&request); err != nil { |
| 91 | msg := fmt.Sprintf("cannot marshall URL [%s] into %T", c.OriginalURL(), request) |
| 92 | ctxLogger.Warn(stacktrace.Propagate(err, msg)) |
| 93 | return h.responseBadRequest(c, err) |
| 94 | } |
| 95 | |
| 96 | if errors := h.validator.ValidateIndex(ctx, request.Sanitize()); len(errors) != 0 { |
| 97 | msg := fmt.Sprintf("validation errors [%s], while fetching discord integrations [%+#v]", spew.Sdump(errors), request) |
| 98 | ctxLogger.Warn(stacktrace.NewError(msg)) |
| 99 | return h.responseUnprocessableEntity(c, errors, "validation errors while fetching discord integrations") |
| 100 | } |
| 101 | |
| 102 | discordIntegrations, err := h.service.Index(ctx, h.userIDFomContext(c), request.ToIndexParams()) |
| 103 | if err != nil { |
| 104 | msg := fmt.Sprintf("cannot get discord integrations with params [%+#v]", request) |
| 105 | ctxLogger.Error(stacktrace.Propagate(err, msg)) |
| 106 | return h.responseInternalServerError(c) |
| 107 | } |
| 108 | |
| 109 | return h.responseOK(c, fmt.Sprintf("fetched %d discord %s", len(discordIntegrations), h.pluralize("integration", len(discordIntegrations))), discordIntegrations) |
| 110 | } |
| 111 | |
| 112 | // Delete a discord integration |
| 113 | // @Summary Delete discord integration |
nothing calls this directly
no test coverage detected