Function Plugs and Module Plugs

These are functions that get a Plug.Conn struct and give a Plug.Conn struct.

How to Create Function Plugs

  1. Create new Module “test” with import Plug.conn
  2. Write the function def function_plug(conn, _options) that uses assign()
  3. In the controller, use that Function Plug Module by importing it
  4. Call function plug :blah
  5. Render it in the view with <%= @conn.assigns[:blah] %>

Function Plugs take 2 items: conn and options. If data is available in conn then use function plugs.

Module Plugs

These need to be initialized.