mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-09 01:18:04 +02:00
Refactor server code (#407)
This commit is contained in:
18
internal/web/handlers/gist/delete.go
Normal file
18
internal/web/handlers/gist/delete.go
Normal file
@ -0,0 +1,18 @@
|
||||
package gist
|
||||
|
||||
import (
|
||||
"github.com/thomiceli/opengist/internal/db"
|
||||
"github.com/thomiceli/opengist/internal/web/context"
|
||||
)
|
||||
|
||||
func DeleteGist(ctx *context.Context) error {
|
||||
gist := ctx.GetData("gist").(*db.Gist)
|
||||
|
||||
if err := gist.Delete(); err != nil {
|
||||
return ctx.ErrorRes(500, "Error deleting this gist", err)
|
||||
}
|
||||
gist.RemoveFromIndex()
|
||||
|
||||
ctx.AddFlash(ctx.Tr("flash.gist.deleted"), "success")
|
||||
return ctx.RedirectTo("/")
|
||||
}
|
Reference in New Issue
Block a user