Skip to content
This repository has been archived by the owner. It is now read-only.

net-engine/resthooks

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
app
 
 
bin
 
 
 
 
db
 
 
lib
 
 
log
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

RESTHooks

Stop polling

http://resthooks.herokuapp.com/

Create resources

All requests must contain HTTP_AUTHORIZATION header with "Token token="USER-TOKEN-PREVIOUSLY-PROVIDED""

There are two main resources. They are called Beers and burgers, and both have a deliciousness field.

Create beers and burgers

All examples will use beers. For burgers, please replace beers and use burgers instead.

You can create beers by posting to /api/v1/beers with the following payload:

{
  "beer": {
    "deliciousness": 3
  }
}
Example using curl
curl "http://localhost/api/v1/beers" \
  -H 'Accept: application/json' -H 'Content-type: application/json' \
  -H "Authorization: Token token=TOKEN-HERE" \
  -X POST \
  -d '{
        "beer": {
          "deliciousness": 3
        }
      }'

Update beers and burgers

You can update them by putting to /api/v1/beers/ID with the following payload:

{
  "beer": {
    "deliciousness": 4
  }
}
Example using curl
curl "http://localhost/api/v1/beers/1" \
  -H 'Accept: application/json' -H 'Content-type: application/json' \
  -H "Authorization: Token token=TOKEN-HERE" \
  -X PUT \
  -d '{
        "beer": {
          "deliciousness": 4
        }
      }'

Using the resthooks for your service

So now you've got beers and burgers, your service can be subscribed to receive updates when they get modified/created/destroyed.

You need to post to /api/v1/resource_subscriptions (user token in header)

{
  "resource_subscription": {
    "post_url": "https://example.com/some_hook?user_id=123",
    "authentication": null,
    "version": 1,
    "resource": "beer"
  }
}
Example using curl
curl "http://localhost/api/v1/resource_subscriptions
  -H 'Accept: application/json' -H 'Content-type: application/json' \
  -H "Authorization: Token token=TOKEN-HERE" \
  -X PUT \
  -d '{
    "resource_subscription": {
      "post_url": "https://example.com/some_hook?user_id=123",
      "authentication": null,
      "version": 1,
      "resource": "beer"
    }
  }'

LICENSE

MIT 2013.

About

A RESTHooks.org reference implementation in Ruby / Rails.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published