/jcrest

Restful interface ot jc

Primary LanguageErlangMIT LicenseMIT

jcrest

Restful interface for JC

Build Status

Introduction

Configuration

  • rebar.config pulls in JC via dependency
  • ip, port, and root defined in sysconfig in jcrest stanza
 {jcrest,
  [       
          {server_ip, "127.0.0.1"},
          {server_port, 8080},
          {server_root, "/"}
  ]
}

compile

$ make compile

run tests

$ make eunit

dialyze

$ make dialyze

Examples

curl -i -X OPTIONS http://127.0.0.1:8080/maps

HTTP/1.1 200 OK
allow: DELETE, GET, HEAD, OPTIONS
content-length: 0
date: Wed, 21 Aug 2019 13:53:37 GMT
server: Cowboy

curl -X PUT -d 'value=200&ttl=100&sequence=10' http://127.0.0.1:8080/maps/unit/3A produces

http://127.0.0.1:8080/maps/  
{
 maps: [
        {
         map_name: "unit",
         links: [
                 {
                  rel: "collection",
                  href: "http://127.0.0.1:8080/maps/*unit*"
                 }
                ]
        }
       ]
}


http://127.0.0.1:8080/maps/*unit*  
{
 map_name: "unit",
 keys: [
        {
         key: "3A",
         links: [
                 {rel: "item",
                  href: "http://127.0.0.1:8080/maps/*unit*/*3A*"
                 }
                ]
        }
       ],
 links: {
         rel: "parent",
         href: "http://127.0.0.1:8080/maps"
        }
}  

http://127.0.0.1:8080/maps/*unit*/*3A*  
{
 map_name: "unit",
 key: "3A",
 value: 200,
 links: [
         {
          rel: "self",
          href: "http://127.0.0.1:8080/maps/*unit*/*3A*"
         },
         {
          rel: "parent",
          href: "http://127.0.0.1:8080/maps/*unit*"
         }
        ]
}