Skip to content

FYI Return values of public facing functions #19

@ff6347

Description

@ff6347

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions