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

Allow inspecting middlewares #43

Merged
merged 1 commit into from
Apr 14, 2021

Conversation

waiting-for-dev
Copy link
Owner

In the same way that 8b3e90b did with operations, this commit adds the
option to inspect middlewares once a WebPipe app has been initialized.

Middlewares are returned as
WebPipe::RackSupport::MiddlewareSpecification instances. They are
returned as an array, as they in fact can be a chain of middlewares
built through middleware composition.

require 'web_pipe'
require 'rack/session'

class MyApp
  include WebPipe

  use :session, Rack::Session::Cookie, key: 'my_app.session', secret: 'long'

  plug(:hello) do |conn|
    conn.set_response_body('Hello world!')
  end
end

app = MyApp.new
session_middleware = app.middlewares[:session][0]
session_middleware.middleware # => Rack::Session::Cookie
session_middleware.options # => [{ key: 'my_app.session', secret: 'long' }]

In the same way that 8b3e90b did with operations, this commit adds the
option to inspect middlewares once a `WebPipe` app has been initialized.

Middlewares are returned as
`WebPipe::RackSupport::MiddlewareSpecification` instances. They are
returned as an array, as they in fact can be a chain of middlewares
built through middleware composition.

```ruby
require 'web_pipe'
require 'rack/session'

class MyApp
  include WebPipe

  use :session, Rack::Session::Cookie, key: 'my_app.session', secret: 'long'

  plug(:hello) do |conn|
    conn.set_response_body('Hello world!')
  end
end

app = MyApp.new
session_middleware = app.middlewares[:session][0]
session_middleware.middleware # => Rack::Session::Cookie
session_middleware.options # => [{ key: 'my_app.session', secret: 'long' }]
```
@waiting-for-dev waiting-for-dev merged commit 2e427c6 into master Apr 14, 2021
@waiting-for-dev waiting-for-dev deleted the waiting-for-dev/inspecting_middlewares branch April 14, 2021 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant