working commit

This commit is contained in:
2026-02-18 23:22:46 +02:00
parent e1ca9b1b4c
commit 4a43a22c19
12 changed files with 500 additions and 92 deletions
+62
View File
@@ -198,3 +198,65 @@ func (hand *Handler) ListFiles(rctx *router.Context) {
}
rctx.SendJSON(code, res.Files)
}
func (hand *Handler) ListCollections(rctx *router.Context) {
cpath, _ := rctx.GetSubpath("path")
if cpath == "" {
cpath = "/"
}
params := &operator.ListCollectionsParams{
Path: cpath,
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
if err != nil {
rctx.SetStatus(http.StatusInternalServerError)
return
}
if !opEnable {
rctx.SetStatus(http.StatusMethodNotAllowed)
return
}
// Execution of the operation
ctx := rctx.GetContext()
code, res, err := hand.oper.ListCollections(ctx, operatorID, params)
if err != nil {
hand.logg.Errorf("ListCollections error: %v", err)
rctx.SetStatus(code)
return
}
rctx.SendJSON(code, res.Collections)
}
func (hand *Handler) DeleteCollection(rctx *router.Context) {
cpath, _ := rctx.GetSubpath("path")
if cpath == "" {
cpath = "/"
}
params := &operator.DeleteColletionParams{
Path: cpath,
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
if err != nil {
rctx.SetStatus(http.StatusInternalServerError)
return
}
if !opEnable {
rctx.SetStatus(http.StatusMethodNotAllowed)
return
}
// Execution of the operation
ctx := rctx.GetContext()
code, res, err := hand.oper.DeleteColletion(ctx, operatorID, params)
if err != nil {
hand.logg.Errorf("DeleteColletion error: %v", err)
rctx.SetStatus(code)
return
}
rctx.SendJSON(code, res.Files)
}