In the function simple I constructed a JSON response using lists. See
|
jsonlite::toJSON(res, auto_unbox = TRUE) |
By reading the docs I found out that we actually don't need this. we just can add the suffix json as in http://localhost:8004/ocpu/library/fhpredict/R/simple/json and we will get some JSON output from it. 🚀
We still should take a look that these return values have a common format. So we don't have on one endpoint {foo:bah} and on the other [1,2,3] https://www.opencpu.org/api.html#api-formats
I guess a function that wrapps return values would be good as the postgres-api does with the fields:
{
"success": true,
"data":[],
"version": "0.1.0",
"message": "wooohooo it worked"
}
So we should:
- always return an data array of objects. Even if it is a "single object function"
- always return the package version
- always return an info of the computation was correct
- if there is a message to tell return it as a string
In the function simple I constructed a JSON response using
lists. Seefhpredict/R/simple.R
Line 21 in 942d467
By reading the docs I found out that we actually don't need this. we just can add the suffix
jsonas inhttp://localhost:8004/ocpu/library/fhpredict/R/simple/jsonand we will get some JSON output from it. 🚀We still should take a look that these return values have a common format. So we don't have on one endpoint
{foo:bah}and on the other[1,2,3]https://www.opencpu.org/api.html#api-formatsI guess a function that wrapps return values would be good as the postgres-api does with the fields:
{ "success": true, "data":[], "version": "0.1.0", "message": "wooohooo it worked" }So we should: