1
0
mirror of https://github.com/rancher/norman.git synced 2025-08-31 14:51:57 +00:00
Files
norman/api/handler/delete.go

28 lines
556 B
Go
Raw Normal View History

2017-11-21 13:46:30 -07:00
package handler
2017-11-10 21:44:02 -07:00
import (
"net/http"
"github.com/rancher/norman/httperror"
2017-11-10 21:44:02 -07:00
"github.com/rancher/norman/types"
)
2018-01-30 16:49:37 -07:00
func DeleteHandler(request *types.APIContext, next types.RequestHandler) error {
2017-11-10 21:44:02 -07:00
store := request.Schema.Store
if store == nil {
return httperror.NewAPIError(httperror.NotFound, "no store found")
2017-11-10 21:44:02 -07:00
}
obj, err := store.Delete(request, request.Schema, request.ID)
if err != nil {
return err
}
if obj == nil {
request.WriteResponse(http.StatusNoContent, nil)
} else {
request.WriteResponse(http.StatusOK, obj)
}
2017-11-10 21:44:02 -07:00
return nil
}