mirror of
https://github.com/rancher/norman.git
synced 2025-09-27 15:44:10 +00:00
More initial dev
This commit is contained in:
30
api/handlers/update.go
Normal file
30
api/handlers/update.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/rancher/norman/types"
|
||||
)
|
||||
|
||||
func UpdateHandler(request *types.APIContext) error {
|
||||
var err error
|
||||
|
||||
validator := request.Schema.Validator
|
||||
if validator != nil {
|
||||
if err := validator(request, request.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
data := request.Body
|
||||
store := request.Schema.Store
|
||||
if store != nil {
|
||||
data, err = store.Update(request, request.Schema, data, request.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
request.WriteResponse(http.StatusOK, data)
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user