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

Method Index

api/pkg/handlers/discord_handler.go:85–110  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

83// @Failure 500 {object} responses.InternalServerError
84// @Router /discord-integrations [get]
85func (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

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