updatet license, added file api docs

This commit is contained in:
2026-03-29 18:36:16 +02:00
parent 31fcdca726
commit 4484d762c2
12 changed files with 322 additions and 82 deletions
+73
View File
@@ -14,6 +14,19 @@ import (
const zeroContentLength = "0"
// GetProperty godoc
//
// @Summary Get file info
// @Description Get file info
// @Tags file
// @Param filepath path string true "File path"
// @Success 200
// @Failure 404,405
// @Router /v3/file/{filepath} [HEAD]
// @Header 200 {int64} Content-Size "File size"
// @Header 200 {string} Content-Digest "File digest"
// @Header 200 {string} Content-Name "File name"
// @Header 200 {string} Content-Collection "File collection"
func (hand *Handler) FileInfo(rctx *router.Context) {
filepath, _ := rctx.GetSubpath("filepath")
@@ -54,6 +67,17 @@ func (hand *Handler) FileInfo(rctx *router.Context) {
rctx.SetStatus(code)
}
// GetProperty godoc
//
// @Summary Store file
// @Description Store file
// @Tags file
// @Param Content-Size header int64 true "File size"
// @Param Content-Type header string true "File type"
// @Param filepath path string true "File path"
// @Success 200
// @Failure 404,405
// @Router /v3/file/{filepath} [PUT]
func (hand *Handler) PutFile(rctx *router.Context) {
contentSize := rctx.GetHeader("Content-Size")
contentType := rctx.GetHeader("Content-Type")
@@ -87,6 +111,17 @@ func (hand *Handler) PutFile(rctx *router.Context) {
rctx.SetStatus(code)
}
// GetProperty godoc
//
// @Summary Get file
// @Description Get file
// @Produce application/octet-stream
// @Produce application/vnd.cncf.helm.chart.content.v1.tar+gzip
// @Tags file
// @Param filepath path string true "File path"
// @Success 200
// @Failure 404,405
// @Router /v3/file/{filepath} [GET]
func (hand *Handler) GetFile(rctx *router.Context) {
filepath, _ := rctx.GetSubpath("filepath")
@@ -135,6 +170,15 @@ func (hand *Handler) GetFile(rctx *router.Context) {
}
}
// GetProperty godoc
//
// @Summary Delete file
// @Description Delete file
// @Tags file
// @Param filepath path string true "File path"
// @Success 200
// @Failure 404,405
// @Router /v3/file/{filepath} [DELETE]
func (hand *Handler) DeleteFile(rctx *router.Context) {
filepath, _ := rctx.GetSubpath("filepath")
@@ -162,6 +206,16 @@ func (hand *Handler) DeleteFile(rctx *router.Context) {
rctx.SetStatus(code)
}
// GetProperty godoc
//
// @Summary List files
// @Description List files
// @Tags file
// @Param path path string true "File path"
// @Success 200 {array} descr.File
// @Failure 404,405
// @Router /v3/files/{path} [GET]
// @Produce application/json
func (hand *Handler) ListFiles(rctx *router.Context) {
filepath, _ := rctx.GetSubpath("filepath")
@@ -200,6 +254,16 @@ func (hand *Handler) ListFiles(rctx *router.Context) {
rctx.SendJSON(code, res.Files)
}
// GetProperty godoc
//
// @Summary List collections
// @Description List collections
// @Tags file
// @Param path path string true "Collection path"
// @Success 200 {array} string
// @Failure 404,405
// @Router /v3/collections/{path} [GET]
// @Produce application/json
func (hand *Handler) ListCollections(rctx *router.Context) {
cpath, _ := rctx.GetSubpath("path")
@@ -237,6 +301,15 @@ func (hand *Handler) ListCollections(rctx *router.Context) {
rctx.SendJSON(code, res.Collections)
}
// GetProperty godoc
//
// @Summary Delete collections
// @Description Delete collections
// @Tags file
// @Param path path string true "Collection path"
// @Success 200
// @Failure 404,405
// @Router /v3/collection/{path} [DELETE]
func (hand *Handler) DeleteCollection(rctx *router.Context) {
cpath, _ := rctx.GetSubpath("path")