34 lines
658 B
Go
Raw Normal View History

2024-04-10 22:10:09 +08:00
package api
import (
"context"
"github.com/loveuer/nf"
"nf-repo/internal/handler"
"nf-repo/internal/interfaces"
"nf-repo/internal/opt"
)
func NewApi(
ctx context.Context,
bh interfaces.BlobHandler,
uh interfaces.UploadHandler,
mh interfaces.ManifestHandler,
) *nf.App {
app := nf.New(nf.Config{BodyLimit: opt.DefaultMaxSize})
{
api := app.Group("/v2")
api.Any("/*path", handler.Root(bh, uh, mh))
}
2024-04-15 18:02:54 +08:00
{
api := app.Group("/api/repo")
api.Get("/settings", handler.RepoSettings)
api.Get("/list", handler.RepoList(mh))
api.Get("/tag/list", handler.TagList(mh))
api.Post("/proxy", handler.ProxyDownloadImage(mh, bh))
}
2024-04-10 22:10:09 +08:00
return app
}