REST

ETS JSON

Simple table-oriented service implementation:

-module(users). -behaviour(rest). -compile({parse_transform, rest}). -include("users.hrl"). -export([init/0, populate/1, exists/1, get/0, get/1, post/1, delete/1]). -rest_record(user). init() -> ets:new(users, [public, named_table, {keypos, #user.id}]). populate(Users) -> ets:insert(users, Users). exists(Id) -> ets:member(users, wf:to_list(Id)). get() -> ets:tab2list(users). get(Id) -> [User] = ets:lookup(users, wf:to_list(Id)), User. delete(Id) -> ets:delete(users, wf:to_list(Id)). post(#user{} = User) -> ets:insert(users, User); post(Data) -> post(from_json(Data, #user{})).

METHODS

$ curl -i -X POST -d "id=vlad" localhost:8005/rest/users $ curl -i -X POST -d "id=doxtop" localhost:8005/rest/users $ curl -i -X GET localhost:8005/rest/users $ curl -i -X PUT -d "id=5HT" localhost:8005/rest/users/vlad $ curl -i -X GET localhost:8005/rest/users/5HT $ curl -i -X DELETE localhost:8005/rest/users/5HT

KVS JSON

Automatik chain-oriented API service implementation:

$ curl -X GET http://localhost:8005/rest/kvs/0/erp/group {"\/erp\/group":[{"name":"Quanterall","url":"quanterall.com", "location":[],"type":[]}]}
$ curl -i -X GET http://localhost:8005/rest/kvs/0/plm/FinaTech-Stamps/income HTTP/1.1 200 OK content-length: 1718 content-type: application/json date: Fri, 04 Oct 2019 15:58:16 GMT server: Cowboy {"\/plm\/FinaTech-Stamps\/income":[{"invoice":"APR-2018-PAY-FTST","account":[], "subaccount":[],"volume":{"fraction":0,"digits":12000},"price":{"fraction":0, "digits":1},"instrument":"USD","type":"crypto","from":[],"to":[]},{"invoice": "AUG-2018-PAY-FTST","account":[],"subaccount":[],"volume":{"fraction":0, "digits":12000},"price":{"fraction":0,"digits":1},"instrument":"USD","type": "crypto","from":[],"to":[]},{"invoice":"FEB-2018-PAY-FTST","account":[], "subaccount":[],"volume":{"fraction":0,"digits":7000},"price":{"fraction":0, "digits":1},"instrument":"USD","type":"crypto","from":[],"to":[]},{"invoice": "JAN-2018-PAY-FTST","account":[],"subaccount":[],"volume":{"fraction":0,"digits": 5000},"price":{"fraction":0,"digits":1},"instrument":"USD","type":"crypto","from": [],"to":[]},{"invoice":"JUL-2018-PAY-FTST","account":[],"subaccount":[],"volume": {"fraction":0,"digits":10000},"price":{"fraction":0,"digits":1},"instrument": "USD","type":"crypto","from":[],"to":[]},{"invoice":"JUN-2018-PAY-FTST", "account":[],"subaccount":[],"volume":{"fraction":0,"digits":10000},"price": {"fraction":0,"digits":1},"instrument":"USD","type":"crypto","from":[],"to":[]}, {"invoice":"MAR-2018-PAY-FTST","account":[],"subaccount":[],"volume": {"fraction":0,"digits":10000},"price":{"fraction":0,"digits":1},"instrument": "USD","type":"crypto","from":[],"to":[]},{"invoice":"MAY-2018-PAY-FTST", "account":[],"subaccount":[],"volume":{"fraction":0,"digits":15000}, "price":{"fraction":0,"digits":1},"instrument":"USD","type":"crypto", "from":[],"to":[]},{"invoice":"SEP-2018-PAY-FTST","account":[],"subaccount": [],"volume":{"fraction":0,"digits":15000},"price":{"fraction":0,"digits":1}, "instrument":"USD","type":"crypto","from":[],"to":[]}]}

MODULES

CREDTIS

  • Dmitry Bushmelev
  • Maxim Sokhatsky