README.md in jersey-0.1.0 vs README.md in jersey-0.2.0
- old
+ new
@@ -147,9 +147,54 @@
class API < Sinatra::Base
register Jersey::Extensions::RouteSignature
end
```
+#### `Jersey::Middleware::AutoJson`
+
+Uses content type matching regex `/json/` or a request body that
+begins with a `{` to detect and parse json. Exposes json
+via `request.body` and `params` so you can transparently
+accept form-encoded and json bodies.
+
+Adds a `#json` method to the `Rack::Request` object.
+
+#### Usage
+Use as a Rack middleware
+
+```ruby
+class API < Sinatra::Base
+ use Jersey::Middleware::AutoJson
+
+ post '/test-json' do
+ request.json == env['rack.json']
+ end
+end
+```
+
+#### `Jersey::Helpers::AutoJsonParams`
+Merges sinatra params Hash with json data parsed by a rack middleware
+that has set `rack.json` on the rack env.
+
+If the parsed data is an array, merges by using the array index as a hash key.
+
+Json data gets precendence in naming collisions.
+
+#### Usage
+Use as a Sinatra Helper
+
+Note: works with any Rack middleware that populates `env['rack.json']`
+
+```ruby
+class API < Sinatra::Base
+ helpers Jersey::Helpers::AutoJsonParams
+
+ post "/test-array-params" do
+ params[0]
+ end
+end
+```
+
#### `Jersey::Middleware::RequestID`
Creates a random request id for every http request, stored both in thread local storage
via the `RequestStore` and in the Rack `env`.