jsend

command
v0.0.0-...-1628972 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 6 Imported by: 0

README

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"}

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