The Plug specification

Plug is a very central component of Phoenix, and as is stated in the documentation, lives at the heart of Phoenix's HTTP layer. The plug specification allows us to compose modules in web applications, abstracting the concept of a connection. Plug embraces the functional nature of Elixir and handles web requests by making a series of transformations on the connection, which eventually will be used to render the response.

There are two types of plugs: function plugs and module plugs. Regardless of the type, Plug's specification is very simple: a Plug must accept a connection and return a (possibly) modified connection. Later in this section, we'll explore what a connection is. Reading this elementary description, it's ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.