Skip to content

Commit

Permalink
use param to enable hard delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Alva8756 committed Nov 15, 2023
1 parent 9089164 commit a962136
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/api/v1/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (r *Router) Routes(rg *gin.RouterGroup) {
{
srv.GET("", amw.RequiredScopes(readScopes("server")), r.serverGet)
srv.PUT("", amw.RequiredScopes(updateScopes("server")), r.serverUpdate)
srv.DELETE("", amw.RequiredScopes(deleteScopes("server")), r.serverDelete)
srv.DELETE("/:hard-delete", amw.RequiredScopes(deleteScopes("server")), r.serverDelete)

// /servers/:uuid/attributes
srvAttrs := srv.Group("/attributes")
Expand Down
4 changes: 3 additions & 1 deletion pkg/api/v1/router_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"reflect"
"strconv"

"github.com/gin-gonic/gin"
"github.com/volatiletech/null/v8"
Expand Down Expand Up @@ -126,7 +127,8 @@ func (r *Router) serverDelete(c *gin.Context) {
return
}

if _, err = dbSRV.Delete(c.Request.Context(), r.DB, false); err != nil {
hardDelete, _ := strconv.ParseBool(c.Param("hard-delete"))
if _, err = dbSRV.Delete(c.Request.Context(), r.DB, hardDelete); err != nil {
dbErrorResponse(c, err)
return
}
Expand Down

0 comments on commit a962136

Please sign in to comment.