1
0
mirror of https://github.com/rancher/norman.git synced 2025-06-03 12:39:25 +00:00
norman/api/handler/create.go

28 lines
460 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
2017-12-12 03:58:43 +00:00
data, err := ParseAndValidateBody(apiContext, true)
2017-11-21 20:46:30 +00:00
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
}