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)
| 145 | // @Failure 500 {object} types.APIInternalServerError "Internal server error" |
| 146 | // @Router /mirror/sources/{id} [get] |
| 147 | func (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 |
no test coverage detected