orbitjs/orbit.js — pull request #46 by pixelhandler (2014-08-06 17:24:53+00:00)
Title: Add JSONPatch header to JSONAPISource application/json-patch+json

## Adds AJAX header for PATCH requests

Per the JSONPATCH spec in section-1 the content type for PATCH is `application/json-patch+json`

http://tools.ietf.org/html/rfc6902#section-1

```
JSON Patch is a format (identified by the media type "application/
json-patch+json") for expressing a sequence of operations to apply to
a target JSON document; it is suitable for use with the HTTP PATCH
method.
```

**Express middleware example:**

https://github.com/expressjs/body-parser

```js
// parse application/json-patch+json as json
app.use(bodyParser.json({ type: 'application/json-patch+json' });
```

**Rails example:**

http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#a-note-about-media-types

* In your controller

```ruby
def update
respond_to do |format|
format.json do
# perform a partial update
@post.update params[:post]
end

format.json_patch do
# perform sophisticated change
end
end
end
```

* In config/initializers/json_patch.rb:

```ruby
Mime::Type.register 'application/json-patch+json', :json_patch
```