README.md in grape-batch-1.1.3 vs README.md in grape-batch-1.1.4

- old
+ new

@@ -45,10 +45,13 @@ ```ruby Grape::Batch.configure do |config| config.limit = 10 config.path = '/batch' config.formatter = Grape::Batch::Response + config.logger = nil + config.session_header = 'HTTP_X_SESSION_TOKEN' + config.session_proc = Proc.new {} end ``` | Argument | Type | Default | Description | :---: | :---: | :---: | :---: @@ -94,9 +97,31 @@ ] } ``` 'body' is optional. + +### Sessions +It's possible ensure a single session during the execution of the batch. You have to specify your session/token/auth header and your session Proc. Before running the batch, the Proc is executed with the data extracted from the specified session header and stored in rack env 'api.session' key. +```ruby +# Example +# Considering the config +Grape::Batch.configure do |config| + config.session_header = 'HTTP_X_SESSION_TOKEN' + config.session_proc = Proc.new {|token| User.where(token: token).first } +end + +# You can build a Grape helper like this +module AuthHelpers + def current_user + if env['api.session'] + env['api.session'] + else + # do authentication stuff + end + end +end +``` ## Contributing 1. Fork it ( https://github.com/c4mprod/grape-batch/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`)