1
0
mirror of https://github.com/rancher/norman.git synced 2025-06-06 05:53:27 +00:00
norman/api/handler/create.go

28 lines
454 B
Go
Raw Normal View History

2017-11-21 20:46:30 +00:00
package handler
import (
"net/http"
"github.com/rancher/norman/types"
)
func CreateHandler(apiContext *types.APIContext) error {
var err error
data, err := ParseAndValidateBody(apiContext)
if err != nil {
return err
}
store := apiContext.Schema.Store
if store != nil {
data, err = store.Create(apiContext, apiContext.Schema, data)
if err != nil {
return err
}
}
apiContext.WriteResponse(http.StatusCreated, data)
return nil
}