本文整理匯總了Golang中github.com/denisbr/filebin/app/model.Tag.Remove方法的典型用法代碼示例。如果您正苦於以下問題:Golang Tag.Remove方法的具體用法?Golang Tag.Remove怎麽用?Golang Tag.Remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/denisbr/filebin/app/model.Tag
的用法示例。
在下文中一共展示了Tag.Remove方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DeleteTag
func DeleteTag(w http.ResponseWriter, r *http.Request, cfg config.Configuration, ctx model.Context) {
var err error
params := mux.Vars(r)
t := model.Tag{}
err = t.SetTag(params["tag"])
if err != nil {
ctx.Log.Println(err)
http.Error(w, "Invalid tag", 400)
return
}
t.SetTagDir(cfg.Filedir)
// Tag does not exist
if t.TagDirExists() == false {
http.Error(w, "Tag Not Found", 404)
return
}
t.List(cfg.Baseurl)
if err != nil {
ctx.Log.Println(err)
http.Error(w, "Internal Server Error", 500)
return
}
if cfg.TriggerDeleteTag != "" {
ctx.Log.Println("Executing trigger: Delete tag")
triggerDeleteTagHandler(cfg.TriggerDeleteTag, t.Tag)
}
// Tag exists, so let's remove it.
err = t.Remove()
if err != nil {
ctx.Log.Println(err)
http.Error(w, "Internal Server Error", 500)
return
}
// Verify that the tag directory is removed before sending the response.
if t.TagDirExists() == true {
// Failsafe. This should not happen.
ctx.Log.Println("Failed to delete the tag. The tag dir still exists.")
http.Error(w, "Internal Server Error", 500)
return
}
// Purging any old content
if cfg.CacheInvalidation {
for _, f := range t.Files {
if err := f.Purge(); err != nil {
ctx.Log.Println(err)
}
}
}
ctx.Log.Println("Tag deleted successfully.")
http.Error(w, "Tag Deleted Successfully", 200)
return
}