mirror of
https://github.com/rancher/norman.git
synced 2025-04-28 11:24:47 +00:00
28 lines
556 B
Go
28 lines
556 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/rancher/norman/httperror"
|
|
"github.com/rancher/norman/types"
|
|
)
|
|
|
|
func DeleteHandler(request *types.APIContext, next types.RequestHandler) error {
|
|
store := request.Schema.Store
|
|
if store == nil {
|
|
return httperror.NewAPIError(httperror.NotFound, "no store found")
|
|
}
|
|
|
|
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)
|
|
}
|
|
return nil
|
|
}
|