34 lines
658 B
Go
34 lines
658 B
Go
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))
|
|
}
|
|
|
|
{
|
|
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))
|
|
}
|
|
|
|
return app
|
|
}
|