Built-in “acceptor” service

The `` acceptor`` service is intended for mass storage of objects of different classes.

Available at <server address>/rest/acceptor.

To work with the service, its registration in the deploy.json application configuration file is required. At the same time, for the service, the repositories dataRepo and metaRepo must be specified in the options. For example

{
  "modules": {
    "rest": {
      "globals": {
        "di": {
          "acceptor": {
            "module": "modules/rest/lib/impl/acceptor",
            "options": {
              "dataRepo": "ion://dataRepo",
              "metaRepo": "ion://metaRepo"
            }
          }

Authorization is carried out through all the main ones: doc: access types <../ authorization / index>.

The service uses the POSTmethod, objects are passed as an array of objects in JSON format in the request body, with the mandatory indication of the json content Content-Type:application/json in the header. You don’t need to specify auto-generated fields.

In the header in the ion-converter property, the name of the converter can be passed, which should be used when processing the data of both the request and the response. In this case, the data converter itself must be registered in the options of the service. If no handler is specified, the default handler is used.

The object data must include:

  • _id - the object ID in the key field
  • _class - object class with namespace
  • _classVer - class version

The other values must match the class properties, including matching data types. Example.

curl -X POST -u demo@local:ion-demo \
   -H "Content-Type:application/json" \
   -d '[{"_class": "class_string@develop-and-test", "__classVer": null,"id": "10101010-5583-11e6-aef7-cf50314f026b",\
       "string_text": "Example10", "string_miltilinetext": "Example10", "string_formattext": "Example10"}]' \
   https://dnt.iondv.com/rest/acceptor

Example of a request to create objects for the acceptor service in dnt: test/modules/rest/acceptor.spec.js

/Checking acceptor service/# basicAuth authorization with admin rights, POSTing strings/# result of creation of objects

The method returns the code 200 and an array of stored objects.

[
  {
    "id": "10101010-5583-11e6-aef7-cf50314f026b",
    "_class": "class_string@develop-and-test",
    "_classVer": "",
    "string_formattext": "Example10",
    "string_miltilinetext": "Example10",
    "string_text": "Example10",
    "_id": "10101010-5583-11e6-aef7-cf50314f026b"
  }
]

In case of an error, the response code will be 400 , and the response text will contain

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Bad Request</pre>
</body>
</html>