mirror of
https://github.com/rancher/norman.git
synced 2025-09-02 07:44:51 +00:00
Add function for parsing and validating an action
This commit is contained in:
@@ -34,3 +34,20 @@ func ParseAndValidateBody(apiContext *types.APIContext, create bool) (map[string
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func ParseAndValidateActionBody(apiContext *types.APIContext, actionInputSchema *types.Schema) (map[string]interface{}, error) {
|
||||
data, err := parse.Body(apiContext.Request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b := builder.NewBuilder(apiContext)
|
||||
|
||||
op := builder.Create
|
||||
data, err = b.Construct(actionInputSchema, data, op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user