update 'driver/generic' now working (~44ms for simplest use)

This commit is contained in:
Adrien Marquès 2018-09-27 14:33:03 +02:00
parent fced676c42
commit 2baee4a066
1 changed files with 14 additions and 4 deletions

View File

@ -45,16 +45,26 @@ func (d *Generic) Load(_path []string, _method string) (func(response.Arguments)
} }
/* (3) Get output json */ /* (3) Get output json */
output := make(response.Arguments) var outputI interface{}
err2 = json.Unmarshal(stdout, output) err2 = json.Unmarshal(stdout, &outputI)
if err2 != nil {
res.Err = err.UncallableController
return *res
}
output, ok := outputI.(map[string]interface{})
if !ok {
res.Err = err.UncallableController
return *res
}
res.Err = err.Success res.Err = err.Success
// extract error (success by default or on error) // extract error (success by default or on error)
if outErr, ok := output["error"]; ok { if outErr, ok := output["error"]; ok {
tmpErr, ok := outErr.(err.Error) errCode, ok := outErr.(float64)
if ok { if ok {
res.Err = tmpErr res.Err = err.Error{int(errCode), "unknown reason", nil}
} }
delete(output, "error") delete(output, "error")