The example project implements a sample REST API with golax
.
How to build and run:
make example && ./_vendor/bin/example
It is a CRUD over a users
collection.
Command:
curl -i http://localhost:8000/service/v1/users/
Result:
HTTP/1.1 200 OK
Date: Sun, 31 Jan 2016 21:15:50 GMT
Content-Length: 8
Content-Type: text/plain; charset=utf-8
[1,2,3]
Command:
curl -i http://localhost:8000/service/v1/users/ --data '{"name":"Oscar"}'
Result:
HTTP/1.1 201 Created
Date: Sun, 31 Jan 2016 21:32:38 GMT
Content-Length: 9
Content-Type: text/plain; charset=utf-8
{"id":4}
Command:
curl -i http://localhost:8000/service/v1/users/4
Result:
HTTP/1.1 200 OK
Date: Sun, 31 Jan 2016 21:33:36 GMT
Content-Length: 43
Content-Type: text/plain; charset=utf-8
{"name":"Oscar","age":0,"introduction":""}
Command:
curl -i http://localhost:8000/service/v1/users/4 \
--data '{"age":70, "introduction": "Hello, I like golax"}'
Result:
HTTP/1.1 200 OK
Date: Sun, 31 Jan 2016 21:35:12 GMT
Content-Length: 0
Content-Type: text/plain; charset=utf-8
Command:
curl -i -X DELETE http://localhost:8000/service/v1/users/1
Result:
HTTP/1.1 200 OK
Date: Sun, 31 Jan 2016 21:36:40 GMT
Content-Length: 0
Content-Type: text/plain; charset=utf-8