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)
| 38 | // @Failure 500 {object} types.APIInternalServerError "Internal server error" |
| 39 | // @Router /mirror/repo [post] |
| 40 | func (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 |
nothing calls this directly
no test coverage detected