package handler import ( "github.com/loveuer/nf" "net/http" "nf-repo/internal/interfaces" "nf-repo/internal/model" "nf-repo/internal/util/rerr" "strconv" ) 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) }