Skip to content

Latest commit

 

History

History

jsend

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

JSend Example

$ go run jsend/main.go

# fetch users
$ curl http://localhost:8080/users
{"status":"success","data":[{"id":"foo","email":"[email protected]"},{"id":"bar","email":"[email protected]"}]}

# create user without required data
$ curl -XPOST  http://localhost:8080/users
{"status":"fail","data":{"email":["email can not be blank"],"id":["id can not be blank"]}}

# create test user
$ curl -XPOST -d "id=test&[email protected]" http://localhost:8080/users
{"status":"success","data":{"id":"test","email":"[email protected]"}}

# refetch users
$ curl http://localhost:8080/users
{"status":"success","data":[{"id":"foo","email":"[email protected]"},{"id":"bar","email":"[email protected]"},{"id":"test","email":"[email protected]"}]}

# fetch test user
$ curl http://localhost:8080/users/test
{"status":"success","data":{"id":"test","email":"[email protected]"}}

# delete test user
$ curl -XDELETE http://localhost:8080/users/test
{"status":"success","data":null}

# refetch test user
$ curl http://localhost:8080/users/test
{"status":"error","data":null,"message":"User Not Found"}