example

command
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2022 License: MIT Imports: 3 Imported by: 0

README

Example project

The example project implements a sample REST API with golax.

Up and running

How to build and run:

make example && ./_vendor/bin/example

The API

It is a CRUD over a users collection.

List user ids GET /service/v1/users/

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]
Create new user POST /service/v1/users/

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}
Get a user GET /service/v1/users/{user_id}

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":""}
Modify a user POST /service/v1/users/{user_id}

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

Delete a user DELETE /service/v1/users/{user_id}

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

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL