What is Elixir Plug?

Is it an abstraction layer between the two

Yes, exactly! Plug is meant to be a generic adapter for different web servers. Currently we support just Cowboy but there is work to support others.

Plug also defines how different components should be plugged together. Similar to Rack in Ruby, WSGI in Python, Ring in Clojure, and so on.


Think of plugs as a pipeline of instructions. The intention of plugs is to take in a conn, modify it and then return the modified conn. You can use plugs for tons of things from attaching headers to requests to verifying that a user is authenticated before rendering certain things. In my current project, I am using plugs to handle the construction of my requests as well as handling authentication.