1
0
mirror of https://github.com/rancher/norman.git synced 2025-04-29 03:44:39 +00:00
norman/api/handler/update.go

29 lines
587 B
Go
Raw Permalink Normal View History

2017-11-21 20:46:30 +00:00
package handler
import (
"net/http"
"github.com/rancher/norman/httperror"
2017-11-21 20:46:30 +00:00
"github.com/rancher/norman/types"
)
2018-01-30 23:49:37 +00:00
func UpdateHandler(apiContext *types.APIContext, next types.RequestHandler) error {
2017-12-12 03:58:43 +00:00
data, err := ParseAndValidateBody(apiContext, false)
2017-11-21 20:46:30 +00:00
if err != nil {
return err
}
store := apiContext.Schema.Store
if store == nil {
return httperror.NewAPIError(httperror.NotFound, "no store found")
}
data, err = store.Update(apiContext, apiContext.Schema, data, apiContext.ID)
if err != nil {
return err
2017-11-21 20:46:30 +00:00
}
apiContext.WriteResponse(http.StatusOK, data)
return nil
}