MCPcopy Create free account
hub / github.com/OpenCSGs/csghub-server / Get

Method Get

api/handler/mirror_source.go:147–174  ·  view source on GitHub ↗

GetMirrorSource godoc @Security ApiKey @Summary Get mirror source @Tags Mirror @Accept json @Produce json @Param id path string true "id" @Success 200 {object} types.Response{data=database.MirrorSource} "OK" @Failure 400 {object} types.APIBadRequest "

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

145// @Failure 500 {object} types.APIInternalServerError "Internal server error"
146// @Router /mirror/sources/{id} [get]
147func (h *MirrorSourceHandler) Get(ctx *gin.Context) {
148 var msId int64
149 id := ctx.Param("id")
150 if id == "" {
151 err := fmt.Errorf("invalid mirror source id")
152 slog.Error("Bad request format", "error", err)
153 httpbase.BadRequest(ctx, err.Error())
154 return
155 }
156 msId, err := strconv.ParseInt(id, 10, 64)
157 if err != nil {
158 slog.Error("Bad request format", "error", err)
159 httpbase.BadRequest(ctx, err.Error())
160 return
161 }
162 currentUser := httpbase.GetCurrentUser(ctx)
163 if currentUser == "" {
164 httpbase.UnauthorizedError(ctx, component.ErrUserNotFound)
165 return
166 }
167 ms, err := h.c.Get(ctx, msId, currentUser)
168 if err != nil {
169 slog.Error("Failed to get mirror source", "error", err)
170 httpbase.ServerError(ctx, err)
171 return
172 }
173 httpbase.OK(ctx, ms)
174}
175
176// DeleteMirrorSource godoc
177// @Security ApiKey

Callers 11

ContentEncodingFunction · 0.45
GetCurrentUserFromHeaderFunction · 0.45
AuthSessionFunction · 0.45
AuthenticatorFunction · 0.45
OnlyAPIKeyAuthenticatorFunction · 0.45
CheckGitlabShellJWTTokenFunction · 0.45
GetUserFromAccessTokenFunction · 0.45
LfsBatchMethod · 0.45
getServiceFunction · 0.45
DatasetPathsInfoMethod · 0.45
HandleMethod · 0.45

Calls 6

BadRequestFunction · 0.92
GetCurrentUserFunction · 0.92
UnauthorizedErrorFunction · 0.92
ServerErrorFunction · 0.92
OKFunction · 0.92
ErrorMethod · 0.80

Tested by

no test coverage detected