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

Method index

api/pkg/handlers/phone_api_key_handler.go:69–94  ·  view source on GitHub ↗

@Summary Get the phone API keys of a user @Description Get list phone API keys which a user has registered on the httpSMS application @Security ApiKeyAuth @Tags PhoneAPIKeys @Accept json @Produce json @Param skip query int false "number of phone api keys to skip"

(c fiber.Ctx)

Source from the content-addressed store, hash-verified

67// @Failure 500 {object} responses.InternalServerError
68// @Router /phone-api-keys [get]
69func (h *PhoneAPIKeyHandler) index(c fiber.Ctx) error {
70 ctx, span, ctxLogger := h.tracer.StartFromFiberCtxWithLogger(c, h.logger)
71 defer span.End()
72
73 var request requests.PhoneAPIKeyIndex
74 if err := c.Bind().Query(&request); err != nil {
75 msg := fmt.Sprintf("cannot marshall params [%s] into %T", c.OriginalURL(), request)
76 ctxLogger.Warn(stacktrace.Propagate(err, msg))
77 return h.responseBadRequest(c, err)
78 }
79
80 if errors := h.validator.ValidateIndex(ctx, request.Sanitize()); len(errors) != 0 {
81 msg := fmt.Sprintf("validation errors [%s], while fetching phone API keys [%+#v]", spew.Sdump(errors), request)
82 ctxLogger.Warn(stacktrace.NewError(msg))
83 return h.responseUnprocessableEntity(c, errors, "validation errors while fetching phone API keys")
84 }
85
86 apiKeys, err := h.service.Index(ctx, h.userIDFomContext(c), request.ToIndexParams())
87 if err != nil {
88 msg := fmt.Sprintf("cannot index phone API keys with params [%+#v]", request)
89 ctxLogger.Error(stacktrace.Propagate(err, msg))
90 return h.responseInternalServerError(c)
91 }
92
93 return h.responseOK(c, fmt.Sprintf("fetched %d phone API %s", len(apiKeys), h.pluralize("key", len(apiKeys))), apiKeys)
94}
95
96// @Summary Store phone API key
97// @Description Creates a new phone API key which can be used to log in to the httpSMS app on your Android phone

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