Skip to content

Commit

Permalink
Add JSONP notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sutto committed May 2, 2012
1 parent de1388e commit aa5dc16
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Expand Up @@ -97,6 +97,27 @@ with the `Cache-Control` header set whilst hitting `GET http://localhost:3000/1/


with the `Etag` header set. with the `Etag` header set.


#### JSONP

If you want to enable JSONP support, it's as simple as calling `jsonp` in your class method:

```ruby
class MyController < RocketPants::Base
jsonp
end
```

By default this will use the `callback` parameter, e.g. `GET /1/my?callback=console.log`.
To change this parameter, specify the `parameter` option like so:

```ruby
class MyController < RocketPants::Base
jsonp :parameter => :jsonp
end
```

Finally, to disable it in a subclass, simple call `jsonp` in the child and pass `:enable => false` as an option.

### Example Client Code ### Example Client Code


Using the example above, we could then use the following to write a client: Using the example above, we could then use the following to write a client:
Expand Down

0 comments on commit aa5dc16

Please sign in to comment.