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

Method CreateMirrorRepo

api/handler/mirror.go:40–62  ·  view source on GitHub ↗

CreateMirrorRepo godoc @Security ApiKey @Summary Create mirror repo @Tags Mirror @Accept json @Produce json @Param body body types.CreateMirrorRepoReq true "body" @Success 200 {object} types.Response{} "OK" @Failure 400 {object} types.APIBadRequest "B

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

38// @Failure 500 {object} types.APIInternalServerError "Internal server error"
39// @Router /mirror/repo [post]
40func (h *MirrorHandler) CreateMirrorRepo(ctx *gin.Context) {
41 var req types.CreateMirrorRepoReq
42 err := ctx.ShouldBindJSON(&req)
43 if err != nil {
44 httpbase.BadRequest(ctx, err.Error())
45 return
46 }
47 currentUser := httpbase.GetCurrentUser(ctx)
48 if currentUser == "" {
49 httpbase.UnauthorizedError(ctx, component.ErrUserNotFound)
50 return
51 }
52 req.CurrentUser = currentUser
53 m, err := h.mc.CreateMirrorRepo(ctx, req)
54 if err != nil {
55 slog.Error("failed to create mirror repo", slog.Any("error", err))
56 httpbase.ServerError(ctx, err)
57 return
58 }
59 slog.Debug("create mirror repo", slog.Any("mirror", m.Repository), slog.Any("req", req))
60
61 httpbase.OK(ctx, nil)
62}
63
64// GetMirrorRepos godoc
65// @Security ApiKey

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected