mirror of
https://github.com/rancher/norman.git
synced 2025-09-01 15:18:20 +00:00
Subcontext and mapping updates
This commit is contained in:
27
api/handler/create.go
Normal file
27
api/handler/create.go
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user