Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 743 Bytes

configuring_the_connection_struct.md

File metadata and controls

25 lines (20 loc) · 743 Bytes

Configuring the connection struct

Extensions add extra behaviour to the connection struct. Sometimes they need some user-provided value to work properly or allow some tweak depending on user needs.

For this reason, you can add configuration data to a WebPipe::Conn instance so that extensions can fetch it. This shared place where extensions look for what they need is the #config attribute, which is very similar to #bag except for its more private intention.

In order to interact with #config, you can use the method #add_config(key, value) or Config plug.

class MyApp
  include WebPipe
  
  plug(:config) do |conn|
    conn.add_config(
      foo: :bar
    )
  end
end