-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#2]: Force data marshaling into JSON object
New path: */v1/get/path/to/the/node+json* Method: *GET* Fixes #2
- Loading branch information
Showing
5 changed files
with
177 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
language: go | ||
go: | ||
- 1.6 | ||
- 1.7 | ||
- 1.8 | ||
- 1.9 | ||
- 1.11 | ||
- 1.12 | ||
|
||
# tests script | ||
script: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
FROM alpine | ||
FROM golang:1.12 AS builder | ||
|
||
COPY . /go/src/github.com/Difrex/zoorest | ||
WORKDIR /go/src/github.com/Difrex/zoorest | ||
|
||
ENV CGO_ENABLED=0 | ||
|
||
RUN go get -t -v ./... | ||
RUN go build -o /zoorest . | ||
|
||
FROM alpine AS final | ||
|
||
MAINTAINER Denis Zheleztsov <[email protected]> | ||
|
||
ADD out/zoorest /bin/ | ||
COPY --from=builder /zoorest /bin/zoorest | ||
|
||
RUN echo -ne "zoorest\nzoorest\n" | adduser zoorest | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# Zoorest | ||
# Zoorest | ||
[![Build Status](https://travis-ci.org/Difrex/zoorest.svg?branch=master)](https://travis-ci.org/Difrex/zoorest) | ||
|
||
Zookeeper HTTP rest API | ||
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again --> | ||
Zookeeper REST API | ||
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> | ||
**Table of Contents** | ||
|
||
- [Zoorest](#zoorest) | ||
|
@@ -11,14 +11,16 @@ Zookeeper HTTP rest API | |
- [List node childrens](#list-node-childrens) | ||
- [Errors](#errors) | ||
- [Get node data](#get-node-data) | ||
- [Errors](#errors) | ||
- [Errors](#errors-1) | ||
- [Get node data as JSON](#get-node-data-as-json) | ||
- [Errors](#errors-2) | ||
- [Create node recursive](#create-node-recursive) | ||
- [Create node children](#create-node-children) | ||
- [Errors](#errors) | ||
- [Errors](#errors-3) | ||
- [Update node](#update-node) | ||
- [Errors](#errors) | ||
- [Errors](#errors-4) | ||
- [Delete node recursive](#delete-node-recursive) | ||
- [Errors](#errors) | ||
- [Errors](#errors-5) | ||
- [Build](#build) | ||
- [Binary](#binary) | ||
- [Docker build](#docker-build) | ||
|
@@ -124,6 +126,65 @@ echo eyJzb21lIjogImpzb24ifQ== | base64 -d | |
} | ||
``` | ||
|
||
### Get node data as JSON | ||
|
||
Method: **GET** | ||
|
||
Location: **/v1/get/path/to/node+json** | ||
|
||
Simple add to the end of the path `+json` | ||
Return JSON | ||
``` | ||
curl -s -XGET http://127.0.0.1:8889/v1/json/one/data+json | jq | ||
{ | ||
"path": "/json/one/data", | ||
"state": "OK", | ||
"error": "", | ||
"zkstat": { | ||
"Czxid": 45, | ||
"Mzxid": 55, | ||
"Ctime": 1564645641612, | ||
"Mtime": 1564646317882, | ||
"Version": 6, | ||
"Cversion": 0, | ||
"Aversion": 0, | ||
"EphemeralOwner": 0, | ||
"DataLength": 28, | ||
"NumChildren": 0, | ||
"Pzxid": 45 | ||
}, | ||
"data": { | ||
"ok": true, | ||
"some": "data" | ||
} | ||
} | ||
``` | ||
|
||
#### Errors | ||
|
||
```json | ||
curl -s -XGET http://127.0.0.1:8889/v1/get/invalid/json+json | jq | ||
{ | ||
"path": "/invalid/json", | ||
"state": "OK", | ||
"error": "JSON parsing failure: invalid character 'i' looking for beginning of value", | ||
"zkstat": { | ||
"Czxid": 45, | ||
"Mzxid": 56, | ||
"Ctime": 1564645641612, | ||
"Mtime": 1564646350753, | ||
"Version": 7, | ||
"Cversion": 0, | ||
"Aversion": 0, | ||
"EphemeralOwner": 0, | ||
"DataLength": 17, | ||
"NumChildren": 0, | ||
"Pzxid": 45 | ||
}, | ||
"data": null | ||
} | ||
``` | ||
|
||
### Create node recursive | ||
|
||
Method: **PUT** | ||
|
@@ -230,11 +291,11 @@ go build -compile gccgo | |
|
||
#### Binary file | ||
|
||
Build binary file | ||
Build binary with the Docker | ||
``` | ||
git clone https://github.com/Difrex/zoorest.git | ||
cd zoorest | ||
./build.sh | ||
./build.sh docker-binary | ||
``` | ||
Result binary file will be placed in out/ dir | ||
|
||
|
@@ -244,7 +305,7 @@ Build Alpine based docker image | |
``` | ||
git clone https://github.com/Difrex/zoorest.git | ||
cd zoorest | ||
./build.sh alpine | ||
./build.sh docker | ||
``` | ||
|
||
Image will be tagged as zoorest:latest | ||
|
@@ -265,7 +326,7 @@ And run it | |
|
||
Denis Zheleztsov <[email protected]> | ||
|
||
# LICENSE | ||
# LICENSE | ||
|
||
GPLv3 see [LICENSE](LICENSE) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,15 @@ | ||
#!/bin/bash | ||
|
||
cat > Dockerfile.builder <<EOF | ||
FROM golang | ||
MAINTAINER Denis Zheleztsov <[email protected]> | ||
ENV GOPATH /usr | ||
RUN go get github.com/Difrex/zoorest/rest | ||
RUN cd /usr/src/github.com/Difrex/zoorest && go get -t -v ./... | ||
WORKDIR /usr/src/github.com/Difrex/zoorest | ||
ENTRYPOINT go build -ldflags "-linkmode external -extldflags -static" && mv zoorest /out | ||
EOF | ||
|
||
# Build builder | ||
docker build --no-cache -t zoorest_builder -f Dockerfile.builder . | ||
# Build bin | ||
docker run -v $(pwd)/out:/out zoorest_builder | ||
|
||
case $1 in alpine) | ||
case $1 in docker) | ||
docker build -t zoorest -f Dockerfile . | ||
;; | ||
binary) | ||
go build -o zoorest . | ||
;; | ||
docker-binary) | ||
docker build --rm -t zoorest -f Dockerfile . | ||
docker run --rm -u root -v $(pwd)/out:/tmp/out --entrypoint '/bin/cp' zoorest /bin/zoorest /tmp/out | ||
;; | ||
*) | ||
;; | ||
;; | ||
esac | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters