Fixed apigw payload processer invalid function registration
This commit is contained in:
@@ -203,7 +203,9 @@ func (h *processerPayload) Merge(params []byte) (types.Handler, error) {
|
||||
return nil, errors.New("could not register function, body empty")
|
||||
}
|
||||
|
||||
h.fn, _ = h.vm.RegisterFunction(h.params.Func)
|
||||
if h.fn, err = h.vm.RegisterFunction(h.params.Func); err != nil {
|
||||
return nil, fmt.Errorf("could not register function, invalid body: %s", err)
|
||||
}
|
||||
|
||||
return h, err
|
||||
}
|
||||
|
||||
@@ -162,6 +162,15 @@ func Test_processerPayload(t *testing.T) {
|
||||
params: prepareFuncPayload(t, ``),
|
||||
errv: `could not register function, body empty`,
|
||||
},
|
||||
{
|
||||
name: "payload processer invalid body",
|
||||
rq: &http.Request{
|
||||
Method: "POST",
|
||||
Body: ioutil.NopCloser(strings.NewReader(`[{"name":"johnny", "surname":"mnemonic"},{"name":"johnny", "surname":"knoxville"}]`)),
|
||||
},
|
||||
params: prepareFuncPayload(t, `.foo`),
|
||||
errv: `could not register function, invalid body: could not transform payload: Unexpected "."`,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user