Defining Web Application Specifications Using Plug
In the previous chapters, we took a deep dive into Cowboy to learn about some of its fundamentals. Then, using that knowledge, we built a web server using :gen_tcp
. However, in both those chapters, we didn’t deal with any sort of complex route matching or other request formats. We will now learn how to accomplish that using the Plug package. In this chapter, we will learn how Plug works, understand some of its main components, and how we can use them to make our web server more usable.
By the end of this chapter, you will know the ins and outs of the Plug package and how Plug enables us to use Cowboy efficiently. You will also learn how to make Plug work with the HTTP server we built in the previous chapter.
In this chapter, we will cover the following topics:
- Philosophy of Plug
- Components of Plug
- The
Plug.Conn
struct - What happens when you send a response using Plug?
- Function plugs and module plugs...