repo.me/internal/handler/catalog.go
loveuer 6e866b83e4 feat: as docker mirror registry
feat: add global proxy config
upgrade: upgrade front(angular) to 19
chore: deployment staff
  1. Dockerfile: build frontend, backend, and run in nginx base image
2024-12-23 22:46:34 -08:00

40 lines
715 B
Go

package handler
import (
"net/http"
"strconv"
"nf-repo/internal/interfaces"
"nf-repo/internal/model"
"nf-repo/internal/tool/rerr"
"github.com/loveuer/nf"
)
func handleCatalog(ctx *nf.Ctx, m interfaces.ManifestHandler) error {
if ctx.Method() != "GET" {
return rerr.Error(ctx, &rerr.RepositoryError{
Status: http.StatusBadRequest,
Code: "METHOD_UNKNOWN",
Message: "We don't understand your method + url",
})
}
nStr := ctx.Query("n")
n := 10000
if nStr != "" {
n, _ = strconv.Atoi(nStr)
}
var (
re *rerr.RepositoryError
list *model.Catalog
)
if list, re = m.Catalog(ctx.Request.Context(), n, 0, ""); re != nil {
return rerr.Error(ctx, re)
}
return ctx.JSON(list)
}