Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 726 Bytes

plugging_operations.md

File metadata and controls

21 lines (17 loc) · 726 Bytes

Plugging operations

You can plug operations into your application with the DSL method plug. The first argument it always takes is a symbol with the name you want to give to the operation (which is needed to allow injection at initialization time).

class MyApp
  include WebPipe
  
  plug :dummy_operation, ->(conn) { conn }
end

Remember, an operation is just a function (in ruby, anything responding to #call) that takes a struct with connection information and returns another instance of it. First operation in the stack receives a struct which has been automatically created with the request data. From then on, any operation can add to it response data.