The Anatomy of a Plug
Before we build our plug, let’s take a deep dive into the Plug library and learn how plugs work from the inside. There are two kinds of plugs: module plugs and function plugs. A function plug is a single function. A module plug is a module that provides two functions with some configuration details. Either way, they work the same.
We have seen both kinds of plugs in use. From the endpoint module in lib/rumbl/endpoint.ex, you can see an example of a module plug:
You specify a module plug by providing the module name. In the router, you can see an example of a function plug:
You specify a function plug with the name of the function as an atom. Because a module is just a collection ...