Go to file
2017-04-17 12:33:05 +03:00
rest Fix path 2017-02-25 16:00:43 +03:00
.travis.yml travis 2017-02-17 14:28:34 +03:00
build.sh -ti removed in binary build 2017-04-17 12:33:05 +03:00
Dockerfile Change user in docker 2017-02-28 15:52:45 +03:00
LICENSE Initial commit 2017-02-17 12:39:42 +03:00
main.go Initial with working ls and get 2017-02-15 17:09:28 +03:00
README.md travis build status image 2017-02-17 14:30:24 +03:00

Zoorest

Build Status

Zookeeper HTTP rest API

Table of Contents

Usage

Usage of ./zoorest:
  -listen string
    	Address to listen (default "127.0.0.1:8889")
  -path string
    	Zk root path (default "/")
  -zk string
    	Zk servers. Comma separated (default "127.0.0.1:2181")

API

List node childrens

Method: GET

Location: /v1/ls

Return JSON

curl -s -XGET http://127.0.0.1:8889/v1/ls/ | jq
{
  "childrens": [
    "two",
    "three",
    "one"
  ],
  "path": "/zoorest",
  "state": "OK",
  "error": ""
}

Errors

curl -s -XGET http://127.0.0.1:8889/v1/ls/does/not/exist | jq
{
  "childrens": null,
  "path": "",
  "state": "ERROR",
  "error": "zk: node does not exist"
}

Get node data

Method: GET

Location: /v1/get

Return JSON

curl -s -XGET http://127.0.0.1:8889/v1/get/one/data | jq
{
  "path": "/zoorest/one/data",
  "state": "OK",
  "error": "",
  "data": "eyJzb21lIjogImpzb24ifQ=="
}

Node data stored in data field as base64 encoded string

echo eyJzb21lIjogImpzb24ifQ== | base64 -d
{"some": "json"}

Errors

 curl -s -XGET http://127.0.0.1:8889/v1/get/does/not/exist | jq
{
  "path": "",
  "state": "ERROR",
  "error": "zk: node does not exist",
  "data": null
}

Create node recursive

Method: PUT

Location: /v1/up

Return string with created path

curl -XPUT http://127.0.0.1:8889/v1/up/two/three/four -d '{"four": "json"}'
/zoorest/two/three/four

Update node

Method: POST

Location: /v1/up

Return string with updated path

curl -XPOST http://127.0.0.1:8889/v1/up/two -d '{"two": "json"}'
/zoorest/two

Errors

curl -XPOST http://127.0.0.1:8889/v1/up/twa -d '{"two": "json"}'
zk: node does not exist

Delete node recursive

Method: DELETE

Location: /v1/rmr

Return string with removed path

curl -XDELETE http://127.0.0.1:8889/v1/rmr/two
/zoorest/two

Errors

curl -XPOST http://127.0.0.1:8889/v1/rmr/two
Method POST not alowed

Build

Binary

Set GOPATH variable

export GOPATH ${HOME}/.local

Get source code

go get github.com/Difrex/zoorest/rest

Get dependencies

cd ${GOPATH}/src/github.com/Difrex/zoorest
go get -t -v ./...

Build staticaly linked binary

go build -ldflags "-linkmode external -extldflags -static"

Build dynamicaly linked binary

go build

Build dynamicaly linked binary with gcc

go build -compile gccgo

Docker build

Binary file

Build binary file

git clone https://github.com/Difrex/zoorest.git
cd zoorest
./build.sh

Result binary file will be placed in out/ dir

Docker image

Build Alpine based docker image

git clone https://github.com/Difrex/zoorest.git
cd zoorest
./build.sh alpine

Image will be tagged as zoorest:latest

AUTHORS

Denis Zheleztsov difrex.punk@gmail.com

LICENSE

GPLv3 see LICENSE