Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension integrating with rack session #21

Merged
merged 1 commit into from
Jul 30, 2019
Merged

Extension integrating with rack session #21

merged 1 commit into from
Jul 30, 2019

Conversation

waiting-for-dev
Copy link
Owner

Wrapper around Rack::Session middlewares.

This extension provides with helper methods to retrieve rack
session and work with it while still being able to chain Conn
method calls.

It requires one of Rack::Session middlewares to be present.

require 'web_pipe'

WebPipe.load_extensions(:session)

class MyApp
  include WebPipe

  use Rack::Cookie, secret: 'top_secret'

  plug :put_session, ->(conn) { conn.put_session('foo', 'bar') }
  plug :fetch_session, ->(conn) { conn.put(:foo, conn.fetch_session('foo')) }
  plug :delete_session, ->(conn) { conn.delete_session('foo') }
  plug :clear_session, ->(conn) { conn.clear_session }
end

Wrapper around Rack::Session middlewares.

This extension provides with helper methods to retrieve rack
session and work with it while still being able to chain `Conn`
method calls.

It requires one of `Rack::Session` middlewares to be present.

```ruby
require 'web_pipe'

WebPipe.load_extensions(:session)

class MyApp
  include WebPipe

  use Rack::Cookie, secret: 'top_secret'

  plug :put_session, ->(conn) { conn.put_session('foo', 'bar') }
  plug :fetch_session, ->(conn) { conn.put(:foo, conn.fetch_session('foo')) }
  plug :delete_session, ->(conn) { conn.delete_session('foo') }
  plug :clear_session, ->(conn) { conn.clear_session }
end
```
@waiting-for-dev waiting-for-dev added the enhancement New feature or request label Jul 30, 2019
@waiting-for-dev waiting-for-dev merged commit df7be09 into master Jul 30, 2019
@waiting-for-dev waiting-for-dev deleted the session branch July 30, 2019 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant