1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-02 15:54:32 +00:00
Files
norman/api/handler/create.go

28 lines
460 B
Go
Raw Normal View History

2017-11-21 13:46:30 -07:00
package handler
import (
"net/http"
"github.com/rancher/norman/types"
)
func CreateHandler(apiContext *types.APIContext) error {
var err error
2017-12-11 20:58:43 -07:00
data, err := ParseAndValidateBody(apiContext, true)
2017-11-21 13:46:30 -07: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
}