Implemented REST API. #3

Merged
merged 2 commits into from Jan 5, 2017

Projects

None yet

2 participants

@anandology
Contributor

Implemented simple RESTful API.

GET /api/rsvps - list all rsvps
POST /api/rsvps - create new rsvp

GET /api/rsvps/ - get rsvp
DELETE /api/rsvps/ - delete rsvp

@cloudyuga cloudyuga merged commit 9271e26 into cloudyuga:master Jan 5, 2017
@anandology
Contributor

Sample Usage:

Get all RSVPs

$ curl http://localhost:5000/api/rsvps
[
 {
  "_id": "586e0e19b1dba7109bb9cf2c",
  "name": "a",
  "links": {
   "self": "http://localhost:5000/api/rsvps/586e0e19b1dba7109bb9cf2c"
  },
  "email": "a@example.com"
 }
]

Create new RSVP

$ curl -H 'content-type: application/json' -d '{"name": "test", "email": "test@example.com"}' 'http://localhost:5000/api/rsvps'
{
 "_id": "586e1afeb1dba716b564b051",
 "name": "test",
 "links": {
  "self": "http://localhost:5000/api/rsvps/586e1afeb1dba716b564b051"
 },
 "email": "test@example.com"
}

Get an RSVP:

$ curl http://localhost:5000/api/rsvps/586e1afeb1dba716b564b051
{
 "_id": "586e1afeb1dba716b564b051",
 "name": "test",
 "links": {
  "self": "http://localhost:5000/api/rsvps/586e1afeb1dba716b564b051"
 },
 "email": "test@example.com"
}

Delete an RSVP:

$ curl -X DELETE http://localhost:5000/api/rsvps/586e1afeb1dba716b564b051
{"deleted": "true"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment