func (ctx *Context) GetTagsHandler(w http.ResponseWriter, r *http.Request) { namespace := mux.Vars(r)["namespace"] repository := mux.Vars(r)["repository"] data := make(map[string]string) dir, err := ctx.storage.ListDirectory(storage.TagPath(namespace, repository)) if err != nil { sendResponse(w, "Repository not found", 404, nil, false) return } for _, fname := range dir { tagName := filepath.Base(fname) if !strings.HasPrefix(tagName, "tag_") { continue } content, err := ctx.storage.GetContent(fname) if err != nil { continue } data[tagName[4:]] = string(content) } sendResponse(w, data, 200, nil, false) }
func (ctx *Context) DeleteRepoHandler(w http.ResponseWriter, r *http.Request) { namespace := mux.Vars(r)["namespace"] repository := mux.Vars(r)["repository"] err := ctx.storage.Remove(storage.TagPath(namespace, repository)) if err != nil { sendResponse(w, "Repository not found", 404, nil, false) return } sendResponse(w, true, 200, nil, false) }